From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1InFtW-0005d3-Gq for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:54:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1InFtV-0005cg-3w for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:54:14 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1InFtU-0005cb-Sx for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:54:12 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1InFrf-00042y-RR for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:20 -0400 Received: from localhost (localhost [127.0.0.1]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id AEEF019D950 for ; Wed, 31 Oct 2007 16:52:12 +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 25201-10 for ; Wed, 31 Oct 2007 16:52:09 +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 8807919D94F for ; Wed, 31 Oct 2007 16:52:08 +0100 (CET) In-Reply-To: <11938459081181@bull.net> Date: Wed, 31 Oct 2007 16:51:50 +0100 Message-Id: <11938459102678@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 1/7] Add arg -disk to define new disk with more features 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 introduces a new parameter allowing to define disks. The new parameter is "-disk": -disk file[,if=3Dtype][,index=3Di][,bus=3Dn][,unit=3Dm][,media=3Dd][,cy= ls=3Dc,heads=3Dh,secs=3Ds[,trans=3Dt]][snapshot=3Don|off] where: file is the disk image type is the interface type (ide) i is the index of the disk on the interface (0, 1, 2, ...) n is the bus number of the given type m is the unit number on the the given bus d is the type of the media (disk, cdrom) c,h,s,t are the parameters usually given by -hdachs snapshot allows to enable or not the snapshot for this disk "-cdrom file" is an alias for "-disk file,index=3D2,media=3Dcdrom" "-hda file" is an alias for "-disk file,index=3D0,media=3Ddisk" "-hdb file" is an alias for "-disk file,index=3D1,media=3Ddisk" "-hdc file" is an alias for "-disk file,index=3D2,media=3Ddisk" "-hdd file" is an alias for "-disk file,index=3D3,media=3Ddisk" "-hda file -hdachs a,b,c" is an alias for=20 "-disk file,index=3D0,cyls=3Da,heads=3Db,secs=3Dc" You can also define a cdrom on the slave of ide0 with: "-disk file,if=3Dide,bus=3D0,unit=3D1,media=3Dcdrom" -- hw/mips_pica61.c | 5 hw/mips_r4k.c | 5 hw/pc.c | 5 hw/ppc_prep.c | 5 monitor.c | 2 vl.c | 346 ++++++++++++++++++++++++++++++++++++++++++++++----= ----- vl.h | 8 - 7 files changed, 311 insertions(+), 65 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 14:12:40.000000000 +0100 +++ qemu/vl.c 2007-10-31 14:18:25.000000000 +0100 @@ -149,9 +149,9 @@ void *ioport_opaque[MAX_IOPORTS]; IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS]; IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS]; -/* Note: bs_table[MAX_DISKS] is a dummy block driver if none available +/* Note: bs_table[MAX_IDE_DISKS] is a dummy block driver if none available to store the VM snapshots */ -BlockDriverState *bs_table[MAX_DISKS + 1], *fd_table[MAX_FD]; +BlockDriverState *bs_table[MAX_IDE_DISKS + 1], *fd_table[MAX_FD]; BlockDriverState *pflash_table[MAX_PFLASH]; BlockDriverState *sd_bdrv; BlockDriverState *mtd_bdrv; @@ -1748,7 +1748,7 @@ case 's': { int i; - for (i =3D 0; i < MAX_DISKS; i++) { + for (i =3D 0; i < MAX_IDE_DISKS; i++) { if (bs_table[i]) bdrv_commit(bs_table[i]); } @@ -4706,6 +4706,205 @@ } } =20 +#define HD_ALIAS ",index=3D%d,media=3Ddisk" + +#ifdef TARGET_PPC +#define CDROM_ALIAS ",index=3D1,media=3Dcdrom" +#else +#define CDROM_ALIAS ",index=3D2,media=3Dcdrom" +#endif + +static int disk_init(const char *str, int snapshot) +{ + char buf[16]; + enum { IF_IDE, IF_SCSI } interface; + enum { MEDIA_DISK, MEDIA_CDROM } media; + int bus_id, unit_id; + int cyls, heads, secs, translation; + char *p; + char *file; + int disk_index; + + file =3D str; + p =3D str; + while (*p !=3D '\0' && *p !=3D ',') + p++; + if (*p =3D=3D ',') { + *p =3D '\0'; + p++; + } + + cyls =3D heads =3D secs =3D 0; + bus_id =3D -1; + unit_id =3D -1; + disk_index =3D -1; + translation =3D BIOS_ATA_TRANSLATION_AUTO; + interface =3D IF_IDE; + media =3D MEDIA_DISK; + + /* extract parameters */ + + if (get_param_value(buf, sizeof(buf), "bus", p)) { + bus_id =3D strtol(buf, NULL, 0); + if (bus_id < 0) { + fprintf(stderr, "qemu: invalid bus id\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "unit", p)) { + unit_id =3D strtol(buf, NULL, 0); + if (unit_id < 0) { + fprintf(stderr, "qemu: invalid unit id\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "index", p)) { + disk_index =3D strtol(buf, NULL, 0); + if (disk_index < 0) { + fprintf(stderr, "qemu: invalid disk index\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "cyls", p)) { + cyls =3D strtol(buf, NULL, 0); + if (cyls < 1 || cyls > 16383) { + fprintf(stderr, "qemu: invalid physical cyls number\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "heads", p)) { + heads =3D strtol(buf, NULL, 0); + if (heads < 1 || heads > 16) { + fprintf(stderr, "qemu: invalid physical heads number\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "secs", p)) { + secs =3D strtol(buf, NULL, 0); + if (secs < 1 || secs > 63) { + fprintf(stderr, "qemu: invalid physical secs number\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "if", p)) { + if (!strcmp(buf, "ide")) + interface =3D IF_IDE; + else if (!strcmp(buf, "scsi")) + interface =3D IF_SCSI; + else { + fprintf(stderr, "unsupported bus type '%s'\n", buf); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "trans", p)) { + if (!strcmp(buf, "none")) + translation =3D BIOS_ATA_TRANSLATION_NONE; + else if (!strcmp(buf, "lba")) + translation =3D BIOS_ATA_TRANSLATION_LBA; + else if (!strcmp(buf, "auto")) + translation =3D BIOS_ATA_TRANSLATION_AUTO; + else { + fprintf(stderr, "qemu: invalid translation type\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "media", p)) { + if (!(strcmp(buf, "disk"))) { + media =3D MEDIA_DISK; + } else if (!strcmp(buf, "cdrom")) { + if (cyls || secs || heads) { + fprintf(stderr, "qemu: invalid physical CHS format\n"); + return -1; + } + media =3D MEDIA_CDROM; + } else { + fprintf(stderr, "qemu: invalid media\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "snapshot", p)) { + if (!(strcmp(buf, "on"))) + snapshot =3D 1; + else if (!(strcmp(buf, "off"))) + snapshot =3D 0; + else { + fprintf(stderr, "qemu: invalid snapshot option\n"); + return -1; + } + } + + switch(interface) { + case IF_IDE: + if (bus_id >=3D MAX_IDE_BUS) { + fprintf(stderr, "qemu: bus number too big\n"); + return -1; + } + if (unit_id >=3D MAX_IDE_DEVS) { + fprintf(stderr, "qemu: unit number too big\n"); + return -1; + } + + if (disk_index =3D=3D -1) { + if (bus_id !=3D -1 && unit_id !=3D -1) { + disk_index =3D bus_id * MAX_IDE_DEVS + unit_id; + } else { + if (bus_id !=3D -1) + disk_index =3D bus_id * MAX_IDE_DEVS; + else + disk_index =3D 0; + while (bs_table[disk_index] && disk_index < MAX_IDE_DISKS) + disk_index++; + } + } + + if (disk_index >=3D MAX_IDE_DISKS) { + fprintf(stderr, "qemu: too many disks\n"); + return -1; + } + + if (!bs_table[disk_index]) { + switch(media) { + case MEDIA_DISK: + snprintf(buf, sizeof(buf), "hd%c", disk_index + 'a'); + bs_table[disk_index] =3D bdrv_new(buf); + break; + case MEDIA_CDROM: + snprintf(buf, sizeof(buf), "cdrom%c", disk_index + '0'); + bs_table[disk_index] =3D bdrv_new(buf); + bdrv_set_type_hint(bs_table[disk_index], BDRV_TYPE_CDROM); + break; + } + + if (file[0] && bdrv_open(bs_table[disk_index], file, + snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { + fprintf(stderr, "qemu: could not open hard disk image '%s'= \n", + file); + return -1; + } + + if (cyls !=3D 0) { + bdrv_set_geometry_hint(bs_table[disk_index], + cyls, heads, secs); + bdrv_set_translation_hint(bs_table[disk_index], translatio= n); + } + } + break; + case IF_SCSI: + /* TODO */ + break; + } + return 0; +} + /***********************************************************/ /* USB devices */ =20 @@ -5489,7 +5688,7 @@ =20 if (bs_snapshots) return bs_snapshots; - for(i =3D 0; i <=3D MAX_DISKS; i++) { + for(i =3D 0; i <=3D MAX_IDE_DISKS; i++) { bs =3D bs_table[i]; if (bdrv_can_snapshot(bs)) goto ok; @@ -5598,7 +5797,7 @@ =20 /* create the snapshots */ =20 - for(i =3D 0; i < MAX_DISKS; i++) { + for(i =3D 0; i < MAX_IDE_DISKS; i++) { bs1 =3D bs_table[i]; if (bdrv_has_snapshot(bs1)) { if (must_delete) { @@ -5641,7 +5840,7 @@ saved_vm_running =3D vm_running; vm_stop(0); =20 - for(i =3D 0; i <=3D MAX_DISKS; i++) { + for(i =3D 0; i <=3D MAX_IDE_DISKS; i++) { bs1 =3D bs_table[i]; if (bdrv_has_snapshot(bs1)) { ret =3D bdrv_snapshot_goto(bs1, name); @@ -5702,7 +5901,7 @@ return; } =20 - for(i =3D 0; i <=3D MAX_DISKS; i++) { + for(i =3D 0; i <=3D MAX_IDE_DISKS; i++) { bs1 =3D bs_table[i]; if (bdrv_has_snapshot(bs1)) { ret =3D bdrv_snapshot_delete(bs1, name); @@ -5731,7 +5930,7 @@ return; } term_printf("Snapshot devices:"); - for(i =3D 0; i <=3D MAX_DISKS; i++) { + for(i =3D 0; i <=3D MAX_IDE_DISKS; i++) { bs1 =3D bs_table[i]; if (bdrv_has_snapshot(bs1)) { if (bs =3D=3D bs1) @@ -6436,7 +6635,7 @@ /* find if the memory block is available on a virtual block device */ sector_num =3D -1; - for(j =3D 0; j < MAX_DISKS; j++) { + for(j =3D 0; j < MAX_IDE_DISKS; j++) { if (bs_table[j]) { sector_num =3D bdrv_hash_find(bs_table[j], phys_ram_base + i, BDRV_HA= SH_BLOCK_SIZE); @@ -6444,7 +6643,7 @@ break; } } - if (j =3D=3D MAX_DISKS) + if (j =3D=3D MAX_IDE_DISKS) goto normal_compress; buf[0] =3D 1; buf[1] =3D j; @@ -6495,7 +6694,7 @@ ram_decompress_buf(s, buf + 1, 9); bs_index =3D buf[1]; sector_num =3D be64_to_cpupu((const uint64_t *)(buf + 2)); - if (bs_index >=3D MAX_DISKS || bs_table[bs_index] =3D=3D NULL)= { + if (bs_index >=3D MAX_IDE_DISKS || bs_table[bs_index] =3D=3D N= ULL) { fprintf(stderr, "Invalid block device index %d\n", bs_inde= x); goto error; } @@ -6996,6 +7195,8 @@ "-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n" "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n" "-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 m= aster)\n" + "-disk file[,if=3Dtype][,index=3Di][,bus=3Dn][,unit=3Dm][,media=3Dd][,= cyls=3Dc,heads=3Dh,secs=3Ds[,trans=3Dt]][snapshot=3Don|off]\n" + " use 'file' as a disk image\n" "-mtdblock file use 'file' as on-board Flash memory image\n" "-sd file use 'file' as SecureDigital card image\n" "-pflash file use 'file' as a parallel flash image\n" @@ -7144,6 +7345,7 @@ QEMU_OPTION_hdb, QEMU_OPTION_hdc, QEMU_OPTION_hdd, + QEMU_OPTION_disk, QEMU_OPTION_cdrom, QEMU_OPTION_mtdblock, QEMU_OPTION_sd, @@ -7232,6 +7434,7 @@ { "hdb", HAS_ARG, QEMU_OPTION_hdb }, { "hdc", HAS_ARG, QEMU_OPTION_hdc }, { "hdd", HAS_ARG, QEMU_OPTION_hdd }, + { "disk", HAS_ARG, QEMU_OPTION_disk }, { "cdrom", HAS_ARG, QEMU_OPTION_cdrom }, { "mtdblock", HAS_ARG, QEMU_OPTION_mtdblock }, { "sd", HAS_ARG, QEMU_OPTION_sd }, @@ -7354,10 +7557,10 @@ { BlockDriverState *bs; =20 - if (index < 4) { + if (index < MAX_IDE_DISKS) { bs =3D bs_table[index]; - } else if (index < 6) { - bs =3D fd_table[index - 4]; + } else if (index < MAX_IDE_DISKS + MAX_FD) { + bs =3D fd_table[index - MAX_IDE_DISKS]; } else { bs =3D NULL; } @@ -7556,10 +7759,10 @@ int use_gdbstub; const char *gdbstub_port; #endif - int i, cdrom_index, pflash_index; + int i, pflash_index; int snapshot, linux_boot; const char *initrd_filename; - const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD]; + const char *fd_filename[MAX_FD]; const char *pflash_filename[MAX_PFLASH]; const char *sd_filename; const char *mtd_filename; @@ -7567,7 +7770,10 @@ DisplayState *ds =3D &display_state; int cyls, heads, secs, translation; char net_clients[MAX_NET_CLIENTS][256]; + char disks[MAX_DISKS][256]; int nb_net_clients; + int nb_disks; + int hda_index; int optind; const char *r, *optarg; CharDriverState *monitor_hd; @@ -7622,8 +7828,6 @@ initrd_filename =3D NULL; for(i =3D 0; i < MAX_FD; i++) fd_filename[i] =3D NULL; - for(i =3D 0; i < MAX_DISKS; i++) - hd_filename[i] =3D NULL; for(i =3D 0; i < MAX_PFLASH; i++) pflash_filename[i] =3D NULL; pflash_index =3D 0; @@ -7639,11 +7843,6 @@ nographic =3D 0; kernel_filename =3D NULL; kernel_cmdline =3D ""; -#ifdef TARGET_PPC - cdrom_index =3D 1; -#else - cdrom_index =3D 2; -#endif cyls =3D heads =3D secs =3D 0; translation =3D BIOS_ATA_TRANSLATION_AUTO; pstrcpy(monitor_device, sizeof(monitor_device), "vc"); @@ -7661,6 +7860,8 @@ usb_devices_index =3D 0; =20 nb_net_clients =3D 0; + nb_disks =3D 0; + hda_index =3D -1; =20 nb_nics =3D 0; /* default mac address of the first network interface */ @@ -7671,7 +7872,10 @@ break; r =3D argv[optind]; if (r[0] !=3D '-') { - hd_filename[0] =3D argv[optind++]; + hda_index =3D nb_disks; + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s" HD_ALIAS, argv[optind++], 0); + nb_disks++; } else { const QEMUOption *popt; =20 @@ -7731,17 +7935,51 @@ initrd_filename =3D optarg; break; case QEMU_OPTION_hda: + if (nb_disks >=3D MAX_DISKS) { + fprintf(stderr, "qemu: too many disks\n"); + exit(1); + } + hda_index =3D nb_disks; + if (cyls =3D=3D 0) + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s" HD_ALIAS, optarg, 0); + else { + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s" HD_ALIAS + ",cyls=3D%d,heads=3D%d,secs=3D%d%s", + optarg, 0, cyls, heads, secs, + translation =3D=3D BIOS_ATA_TRANSLATION_LBA ? + ",trans=3Dlba" : + translation =3D=3D BIOS_ATA_TRANSLATION_NONE ? + ",trans=3Dnone" : ""); + } + nb_disks++; + break; case QEMU_OPTION_hdb: case QEMU_OPTION_hdc: case QEMU_OPTION_hdd: { int hd_index; + if (nb_disks >=3D MAX_DISKS) { + fprintf(stderr, "qemu: too many disks\n"); + exit(1); + } hd_index =3D popt->index - QEMU_OPTION_hda; - hd_filename[hd_index] =3D optarg; - if (hd_index =3D=3D cdrom_index) - cdrom_index =3D -1; + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s" HD_ALIAS, optarg, hd_index); + nb_disks++; } break; + case QEMU_OPTION_disk: + if (nb_disks >=3D MAX_DISKS) { + fprintf(stderr, "qemu: too many disks\n"); + exit(1); + } + pstrcpy(disks[nb_disks], + sizeof(disks[0]), + optarg); + nb_disks++; + break; case QEMU_OPTION_mtdblock: mtd_filename =3D optarg; break; @@ -7792,6 +8030,15 @@ fprintf(stderr, "qemu: invalid physical CHS format= \n"); exit(1); } + if (hda_index !=3D -1) + snprintf(disks[hda_index] + strlen(disks[hda_index]), + sizeof(disks[0]) - strlen(disks[hda_index]), + ",cyls=3D%d,heads=3D%d,secs=3D%d%s", + cyls, heads, secs, + translation =3D=3D BIOS_ATA_TRANSLATION_LBA ? + ",trans=3Dlba" : + translation =3D=3D BIOS_ATA_TRANSLATION_NONE ? + ",trans=3Dnone" : ""); } break; case QEMU_OPTION_nographic: @@ -7810,9 +8057,13 @@ kernel_cmdline =3D optarg; break; case QEMU_OPTION_cdrom: - if (cdrom_index >=3D 0) { - hd_filename[cdrom_index] =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" CDROM_ALIAS, optarg); + nb_disks++; break; case QEMU_OPTION_boot: if (strlen(optarg) > MAX_BOOT_DEVICES) { @@ -8179,14 +8430,13 @@ =20 if (!linux_boot && (!strchr(boot_device, 'n')) && - hd_filename[0] =3D=3D '\0' && - (cdrom_index >=3D 0 && hd_filename[cdrom_index] =3D=3D '\0') && + nb_disks =3D=3D 0 && fd_filename[0] =3D=3D '\0') help(1); =20 /* boot to floppy or the default cd if no hard disk defined yet */ if (!boot_device[0]) { - if (hd_filename[0] !=3D '\0') + if (nb_disks) boot_device[0] =3D 'c'; else if (fd_filename[0] !=3D '\0') boot_device[0] =3D 'a'; @@ -8261,32 +8511,20 @@ exit(1); } =20 - /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); - if (cdrom_index >=3D 0) { - bs_table[cdrom_index] =3D bdrv_new("cdrom"); - bdrv_set_type_hint(bs_table[cdrom_index], BDRV_TYPE_CDROM); + + /* we always create the cdrom drive, even if no disk is there */ + + if (nb_disks < MAX_DISKS) { + pstrcpy(disks[nb_disks], sizeof(disks[0]), CDROM_ALIAS); + nb_disks++; } =20 /* open the virtual block devices */ - for(i =3D 0; i < MAX_DISKS; i++) { - if (hd_filename[i]) { - if (!bs_table[i]) { - char buf[64]; - snprintf(buf, sizeof(buf), "hd%c", i + 'a'); - bs_table[i] =3D bdrv_new(buf); - } - if (bdrv_open(bs_table[i], hd_filename[i], snapshot ? BDRV_O_S= NAPSHOT : 0) < 0) { - fprintf(stderr, "qemu: could not open hard disk image '%s'= \n", - hd_filename[i]); - exit(1); - } - if (i =3D=3D 0 && cyls !=3D 0) { - bdrv_set_geometry_hint(bs_table[i], cyls, heads, secs); - bdrv_set_translation_hint(bs_table[i], translation); - } - } - } + + for(i =3D 0; i < nb_disks; i++) + if (disk_init(disks[i], snapshot) =3D=3D -1) + exit(1); =20 /* we always create at least one floppy disk */ fd_table[0] =3D bdrv_new("fda"); 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 14:12:40.000000000 +0100 +++ qemu/vl.h 2007-10-31 14:13:20.000000000 +0100 @@ -984,9 +984,13 @@ extern uint8_t _translate_keycode(const int key); =20 /* ide.c */ -#define MAX_DISKS 4 +#define MAX_IDE_BUS 2 +#define MAX_IDE_DEVS 2 +#define MAX_IDE_DISKS (MAX_IDE_BUS * MAX_IDE_DEVS) =20 -extern BlockDriverState *bs_table[MAX_DISKS + 1]; +#define MAX_DISKS (MAX_IDE_DISKS) + +extern BlockDriverState *bs_table[MAX_IDE_DISKS + 1]; extern BlockDriverState *sd_bdrv; extern BlockDriverState *mtd_bdrv; =20 Index: qemu/monitor.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/monitor.c 2007-10-31 14:12:18.000000000 +0100 +++ qemu/monitor.c 2007-10-31 14:13:20.000000000 +0100 @@ -204,7 +204,7 @@ int i, all_devices; =20 all_devices =3D !strcmp(device, "all"); - for (i =3D 0; i < MAX_DISKS; i++) { + for (i =3D 0; i < MAX_IDE_DISKS; i++) { if (bs_table[i]) { if (all_devices || !strcmp(bdrv_get_device_name(bs_table[i]), device)) Index: qemu/hw/mips_pica61.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/hw/mips_pica61.c 2007-10-31 14:12:40.000000000 +0100 +++ qemu/hw/mips_pica61.c 2007-10-31 14:13:20.000000000 +0100 @@ -136,9 +136,10 @@ i8042_mm_init(i8259[6], i8259[7], 0x80005060, 0); =20 /* IDE controller */ - for(i =3D 0; i < 2; i++) + for(i =3D 0; i < MAX_IDE_BUS; i++) isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i + 1]); + bs_table[MAX_IDE_DEVS * i], + bs_table[MAX_IDE_DEVS * i + 1]); =20 /* Network controller */ /* FIXME: missing NS SONIC DP83932 */ Index: qemu/hw/mips_r4k.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/hw/mips_r4k.c 2007-10-31 14:12:40.000000000 +0100 +++ qemu/hw/mips_r4k.c 2007-10-31 14:13:20.000000000 +0100 @@ -240,9 +240,10 @@ } } =20 - for(i =3D 0; i < 2; i++) + for(i =3D 0; i < MAX_IDE_BUS; i++) isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i + 1]); + bs_table[MAX_IDE_DEVS * i], + bs_table[MAX_IDE_DEVS * i + 1]); =20 i8042_init(i8259[1], i8259[12], 0x60); ds1225y_init(0x9000, "nvram"); Index: qemu/hw/pc.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/hw/pc.c 2007-10-31 14:12:40.000000000 +0100 +++ qemu/hw/pc.c 2007-10-31 14:13:20.000000000 +0100 @@ -892,9 +892,10 @@ if (pci_enabled) { pci_piix3_ide_init(pci_bus, bs_table, piix3_devfn + 1, i8259); } else { - for(i =3D 0; i < 2; i++) { + for(i =3D 0; i < MAX_IDE_BUS; i++) { isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i + 1]); + bs_table[MAX_IDE_DEVS * i], + bs_table[MAX_IDE_DEVS * i + 1]); } } =20 Index: qemu/hw/ppc_prep.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/hw/ppc_prep.c 2007-10-31 14:12:40.000000000 +0100 +++ qemu/hw/ppc_prep.c 2007-10-31 14:13:20.000000000 +0100 @@ -649,9 +649,10 @@ } } =20 - for(i =3D 0; i < 2; i++) { + for(i =3D 0; i < MAX_IDE_BUS; i++) { isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i + 1]); + bs_table[MAX_IDE_DEVS * i], + bs_table[MAX_IDE_DEVS * i + 1]); } i8042_init(i8259[1], i8259[12], 0x60); DMA_init(1);