From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1InFrs-00041k-Gr for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1InFrr-00041K-G1 for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:31 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1InFrr-00041F-B2 for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:31 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1InFrq-00047Z-D3 for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:31 -0400 Received: from localhost (localhost [127.0.0.1]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 2BBF819D94F for ; Wed, 31 Oct 2007 16:52:23 +0100 (CET) Received: from ecfrec.frec.bull.fr ([127.0.0.1]) by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 25561-03 for ; Wed, 31 Oct 2007 16:52:19 +0100 (CET) Received: from ecn002.frec.bull.fr (ecn002.frec.bull.fr [129.183.4.6]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id CA46419D98C for ; Wed, 31 Oct 2007 16:52:15 +0100 (CET) In-Reply-To: <11938459183031@bull.net> Date: Wed, 31 Oct 2007 16:51:59 +0100 Message-Id: <1193845919419@bull.net> Mime-Version: 1.0 From: Laurent Vivier Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Subject: [Qemu-devel] [PATCH 7/7] Add SecureDigital support by -disk Reply-To: Laurent Vivier , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Laurent.Vivier@bull.net This patch allows to define SecureDigital disk using "-disk" syntax" It adds an interface type "sd" "-sd file" becomes the alias of "-disk file,if=3Dsd" -- vl.c | 43 ++++++++++++++++++++++++++----------------- vl.h | 3 ++- 2 files changed, 28 insertions(+), 18 deletions(-) Index: qemu/vl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- qemu.orig/vl.c 2007-10-31 15:05:44.000000000 +0100 +++ qemu/vl.c 2007-10-31 15:10:48.000000000 +0100 @@ -4714,6 +4714,7 @@ #define FD_ALIAS ",index=3D%d,if=3Dfloppy" #define PFLASH_ALIAS ",if=3Dpflash" #define MTD_ALIAS ",if=3Dmtd" +#define SD_ALIAS ",if=3Dsd" #define HD_ALIAS ",index=3D%d,media=3Ddisk" =20 #ifdef TARGET_PPC @@ -4725,7 +4726,7 @@ static int disk_init(const char *str, int snapshot, QEMUMachine *machine) { char buf[16]; - enum { IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD } interface; + enum { IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD } interfac= e; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; @@ -4820,6 +4821,8 @@ interface =3D IF_PFLASH; else if (!strcmp(buf, "mtd")) interface =3D IF_MTD; + else if (!strcmp(buf, "sd")) + interface =3D IF_SD; else { fprintf(stderr, "unsupported bus type '%s'\n", buf); return -1; @@ -5034,6 +5037,21 @@ } } break; + case IF_SD: + if (!sd_bdrv) { + sd_bdrv =3D bdrv_new ("sd"); + /* FIXME: This isn't really a floppy, but it's a reasonable + approximation. */ + bdrv_set_type_hint(sd_bdrv, BDRV_TYPE_FLOPPY); + if (file[0] && bdrv_open(sd_bdrv, file, + snapshot ? BDRV_O_SNAPSHOT : 0) < 0 + || qemu_key_check(sd_bdrv, file)) { + fprintf(stderr, "qemu: could not open SD card image %s\n", + file); + return -1; + } + } + break; } return 0; } @@ -7916,7 +7934,6 @@ int i; int snapshot, linux_boot; const char *initrd_filename; - const char *sd_filename; const char *kernel_filename, *kernel_cmdline; DisplayState *ds =3D &display_state; int cyls, heads, secs, translation; @@ -7977,7 +7994,6 @@ machine =3D first_machine; cpu_model =3D NULL; initrd_filename =3D NULL; - sd_filename =3D NULL; ram_size =3D DEFAULT_RAM_SIZE * 1024 * 1024; vga_ram_size =3D VGA_RAM_SIZE; #ifdef CONFIG_GDBSTUB @@ -8135,7 +8151,13 @@ nb_disks++; break; case QEMU_OPTION_sd: - sd_filename =3D optarg; + if (nb_disks >=3D MAX_DISKS) { + fprintf(stderr, "qemu: too many disks\n"); + exit(1); + } + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s" SD_ALIAS, optarg); + nb_disks++; break; case QEMU_OPTION_pflash: if (nb_disks >=3D MAX_DISKS) { @@ -8682,19 +8704,6 @@ if (disk_init(disks[i], snapshot, machine) =3D=3D -1) exit(1); =20 - sd_bdrv =3D bdrv_new ("sd"); - /* FIXME: This isn't really a floppy, but it's a reasonable - approximation. */ - bdrv_set_type_hint(sd_bdrv, BDRV_TYPE_FLOPPY); - if (sd_filename) { - if (bdrv_open(sd_bdrv, sd_filename, - snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { - fprintf(stderr, "qemu: could not open SD card image %s\n", - sd_filename); - } else - qemu_key_check(sd_bdrv, sd_filename); - } - register_savevm("timer", 0, 2, timer_save, timer_load, NULL); register_savevm("ram", 0, 2, ram_save, ram_load, NULL); =20 Index: qemu/vl.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- qemu.orig/vl.h 2007-10-31 15:05:44.000000000 +0100 +++ qemu/vl.h 2007-10-31 15:10:48.000000000 +0100 @@ -995,9 +995,10 @@ #define MAX_IDE_DISKS (MAX_IDE_BUS * MAX_IDE_DEVS) =20 #define MAX_MTD 1 +#define MAX_SD 1 =20 #define MAX_DISKS (MAX_IDE_DISKS + MAX_SCSI_DISKS + MAX_FD + MAX_PFLASH + \ - MAX_MTD) + MAX_MTD + MAX_SD) =20 extern BlockDriverState *bs_table[MAX_IDE_DISKS + 1]; extern BlockDriverState *sd_table[MAX_SCSI_DISKS + 1];