* [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target @ 2007-10-28 22:43 Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Laurent.Vivier 2007-10-31 9:50 ` [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target Dan Kenigsberg 0 siblings, 2 replies; 27+ messages in thread From: Laurent.Vivier @ 2007-10-28 22:43 UTC (permalink / raw) To: qemu-devel Hi, I know this has already been tried, but I hope this time I have the good approach: this series of 3 patches introduces the support of SCSI devices for the PC target (and try to break nothing existing). [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom This patch allows to define where is connected the CDROM device. [PATCH 2/3] Add arg -disk to define new disk with more features As for "-cdrom", this patch introduces a new parameters allowing to define more information for a disk. [PATCH 3/3] Add scsi support to pc target This patch add the support of SCSI disk and cdrom for PC target. ^ permalink raw reply [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-28 22:43 [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target Laurent.Vivier @ 2007-10-28 22:43 ` Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 2/3] Add arg -disk to define new disk with more features Laurent.Vivier ` (2 more replies) 2007-10-31 9:50 ` [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target Dan Kenigsberg 1 sibling, 3 replies; 27+ messages in thread From: Laurent.Vivier @ 2007-10-28 22:43 UTC (permalink / raw) To: qemu-devel From: Laurent Vivier <vivierl@frecb07144.(none)> This patch allows to define where is connected the CDROM device (bus, unit). It extends the "-cdrom" syntax to add these paramaters: -cdrom file[,if=type][,bus=n][,unit=m] where "type" defines the interface (by default, "ide") "n" defines the bus number (by default 1) "m" defines the unit number (by default 0) --- vl.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 101 insertions(+), 22 deletions(-) diff --git a/vl.c b/vl.c index f9500a9..a8c4a81 100644 --- a/vl.c +++ b/vl.c @@ -4701,6 +4701,79 @@ void do_info_network(void) } } +#define MAX_CDROMS 4 +#ifdef TARGET_PPC +#define DEFAULT_CDROM_BUS 0 +#define DEFAULT_CDROM_UNIT 1 +#define DEFAULT_CDROM_IF "ide" +#else +#define DEFAULT_CDROM_BUS 1 +#define DEFAULT_CDROM_UNIT 0 +#define DEFAULT_CDROM_IF "ide" +#endif + +static int cdrom_init(const char *str) +{ + char *p; + char *file; + char buf[16]; + char interface[16]; + int bus_id, unit_id; + + bus_id = DEFAULT_CDROM_BUS; + unit_id = DEFAULT_CDROM_UNIT; + pstrcpy(interface, sizeof(interface), DEFAULT_CDROM_IF); + file = str; + + if (str) { + p = str; + while (*p != '\0' && *p != ',') + p++; + if (*p == ',') { + *p = '\0'; + p++; + } + + if (get_param_value(buf, sizeof(buf), "bus", p)) { + bus_id = strtol(buf, NULL, 0); + } + + if (get_param_value(buf, sizeof(buf), "unit", p)) { + unit_id = strtol(buf, NULL, 0); + } + + if (get_param_value(buf, sizeof(buf), "if", p)) { + pstrcpy(interface, sizeof(interface), buf); + } + } + + if (strcmp(interface, "ide") == 0) { + int cdrom_index = bus_id * 2 + unit_id; + + if (cdrom_index > MAX_DISKS) { + fprintf(stderr, "Invalid cdrom address bus=%d,unit=%d\n", + bus_id, unit_id); + return -1; + } + + bs_table[cdrom_index] = bdrv_new("cdrom"); + bdrv_set_type_hint(bs_table[cdrom_index], BDRV_TYPE_CDROM); + + if (file && bdrv_open(bs_table[cdrom_index], file, 0) < 0) { + fprintf(stderr, "qemu: could not open cdrom image '%s'\n", + file); + return -1; + } + return 0; + } else if (strcmp(interface, "scsi") == 0) { + /* TODO */ + } + + fprintf(stderr, "unsupported bus type '%s' for cdrom '%s'\n", + interface, file); + return -1; +} + /***********************************************************/ /* USB devices */ @@ -6990,7 +7063,9 @@ static void help(int exitcode) "-fda/-fdb file use 'file' as floppy disk 0/1 image\n" "-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 master)\n" + "-cdrom file[,if=type][,bus=n][,unit=m]\n" + " use 'file' as cdrom image\n" + " (by default cdrom is ide1 master (if=ide,bus=1,unit=0))\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" @@ -7551,7 +7626,7 @@ int main(int argc, char **argv) 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]; @@ -7562,7 +7637,9 @@ int main(int argc, char **argv) DisplayState *ds = &display_state; int cyls, heads, secs, translation; char net_clients[MAX_NET_CLIENTS][256]; + char cdroms[MAX_CDROMS][256]; int nb_net_clients; + int nb_cdroms; int optind; const char *r, *optarg; CharDriverState *monitor_hd; @@ -7634,11 +7711,6 @@ int main(int argc, char **argv) nographic = 0; kernel_filename = NULL; kernel_cmdline = ""; -#ifdef TARGET_PPC - cdrom_index = 1; -#else - cdrom_index = 2; -#endif cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; pstrcpy(monitor_device, sizeof(monitor_device), "vc"); @@ -7656,6 +7728,7 @@ int main(int argc, char **argv) usb_devices_index = 0; nb_net_clients = 0; + nb_cdroms = 0; nb_nics = 0; /* default mac address of the first network interface */ @@ -7733,8 +7806,6 @@ int main(int argc, char **argv) int hd_index; hd_index = popt->index - QEMU_OPTION_hda; hd_filename[hd_index] = optarg; - if (hd_index == cdrom_index) - cdrom_index = -1; } break; case QEMU_OPTION_mtdblock: @@ -7805,9 +7876,14 @@ int main(int argc, char **argv) kernel_cmdline = optarg; break; case QEMU_OPTION_cdrom: - if (cdrom_index >= 0) { - hd_filename[cdrom_index] = optarg; + if (nb_cdroms >= MAX_CDROMS) { + fprintf(stderr, "qemu: too many cdroms\n"); + exit(1); } + pstrcpy(cdroms[nb_cdroms], + sizeof(cdroms[0]), + optarg); + nb_cdroms++; break; case QEMU_OPTION_boot: boot_device = optarg[0]; @@ -8170,7 +8246,7 @@ int main(int argc, char **argv) if (!linux_boot && boot_device != 'n' && hd_filename[0] == '\0' && - (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') && + (nb_cdroms >= 0 && cdroms[0] == '\0') && fd_filename[0] == '\0') help(1); @@ -8249,21 +8325,24 @@ int main(int argc, char **argv) exit(1); } - /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); - if (cdrom_index >= 0) { - bs_table[cdrom_index] = 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_cdroms == 0) && (cdrom_init(NULL) == -1)) + exit(1); + + for (i = 0; i < nb_cdroms; i++) + if (cdrom_init(cdroms[i]) == -1) + exit(1); /* open the virtual block devices */ for(i = 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] = bdrv_new(buf); - } + char buf[64]; + snprintf(buf, sizeof(buf), "hd%c", i + 'a'); + bs_table[i] = bdrv_new(buf); + if (bdrv_open(bs_table[i], hd_filename[i], snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { fprintf(stderr, "qemu: could not open hard disk image '%s'\n", hd_filename[i]); -- 1.4.4.4 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 2/3] Add arg -disk to define new disk with more features 2007-10-28 22:43 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Laurent.Vivier @ 2007-10-28 22:43 ` Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 3/3] Add scsi support to pc target Laurent.Vivier 2007-10-29 12:03 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Johannes Schindelin 2007-10-29 13:25 ` Daniel P. Berrange 2 siblings, 1 reply; 27+ messages in thread From: Laurent.Vivier @ 2007-10-28 22:43 UTC (permalink / raw) To: qemu-devel From: Laurent Vivier <vivierl@frecb07144.(none)> As for "-cdrom", this patch introduces a new parameter allowing to define more information for a disk. The new parameter is "-disk": -disk file[,if=type][,bus=n][,unit=m][,cyls=c,heads=h,secs=s[,trans=t]] where "type" defines the bus type (by default "ide") "n" the bus number (by default 0) "m" the unit number (by default 0) and c,h,s and t define the disk geometry (like -hdachs) --- vl.c | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 173 insertions(+), 24 deletions(-) diff --git a/vl.c b/vl.c index a8c4a81..8408ce4 100644 --- a/vl.c +++ b/vl.c @@ -4701,6 +4701,114 @@ void do_info_network(void) } } +static int disk_init(const char *str, int snapshot) +{ + char buf[16]; + char interface[16]; + int bus_id, unit_id; + int cyls, heads, secs, translation; + char *p; + char *file; + + file = str; + p = str; + while (*p != '\0' && *p != ',') + p++; + if (*p == ',') { + *p = '\0'; + p++; + } + + cyls = heads = secs = 0; + bus_id = -1; + unit_id = -1; + translation = BIOS_ATA_TRANSLATION_AUTO; + pstrcpy(interface, sizeof(interface), "ide"); + + if (get_param_value(buf, sizeof(buf), "bus", p)) { + bus_id = strtol(buf, NULL, 0); + } + + if (get_param_value(buf, sizeof(buf), "unit", p)) { + unit_id = strtol(buf, NULL, 0); + } + + if (get_param_value(buf, sizeof(buf), "cyls", p)) { + cyls = strtol(buf, NULL, 0); + } + + if (get_param_value(buf, sizeof(buf), "heads", p)) { + heads = strtol(buf, NULL, 0); + } + + if (get_param_value(buf, sizeof(buf), "secs", p)) { + secs = strtol(buf, NULL, 0); + } + + if (get_param_value(buf, sizeof(buf), "if", p)) { + pstrcpy(interface, sizeof(interface), buf); + } + + if (get_param_value(buf, sizeof(buf), "trans", p)) { + if (!strcmp(buf, "none")) + translation = BIOS_ATA_TRANSLATION_NONE; + else if (!strcmp(buf, "lba")) + translation = BIOS_ATA_TRANSLATION_LBA; + else if (!strcmp(buf, "auto")) + translation = BIOS_ATA_TRANSLATION_AUTO; + else + translation = -1; + } + + if ( (cyls || secs || heads) && + ( (cyls < 1 || cyls > 16383) || + (heads < 1 || heads > 16) || + (secs < 1 || secs > 63) || + (translation == -1) ) ) { + fprintf(stderr, "qemu: invalid physical CHS format\n"); + return -1; + } + + if (strcmp(interface, "ide") == 0) { + static int disk_index = -1; + + disk_index++; + + if (bus_id == -1) { + bus_id = disk_index / 2; + if (unit_id == -1) + unit_id = disk_index % 2; + } else if (unit_id == -1) + unit_id = 0; + + disk_index = bus_id * 2 + unit_id; + + snprintf(buf, sizeof(buf), "hd%c", disk_index + 'a'); + + bs_table[disk_index] = bdrv_new(buf); + + if (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 != 0) { + bdrv_set_geometry_hint(bs_table[disk_index], + cyls, heads, secs); + bdrv_set_translation_hint(bs_table[disk_index], translation); + } + return 0; + } else if (strcmp(interface, "scsi") == 0) { + /* TODO */ + } + + fprintf(stderr, "unsupported bus type '%s' for cdrom '%s'\n", + interface, file); + return -1; +} + #define MAX_CDROMS 4 #ifdef TARGET_PPC #define DEFAULT_CDROM_BUS 0 @@ -7063,6 +7171,8 @@ static void help(int exitcode) "-fda/-fdb file use 'file' as floppy disk 0/1 image\n" "-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" + "-disk file[,if=type][,bus=n][,unit=m][,cyls=c,heads=h,secs=s[,trans=t]]\n" + " use 'file' as a disk image\n" "-cdrom file[,if=type][,bus=n][,unit=m]\n" " use 'file' as cdrom image\n" " (by default cdrom is ide1 master (if=ide,bus=1,unit=0))\n" @@ -7214,6 +7324,7 @@ enum { QEMU_OPTION_hdb, QEMU_OPTION_hdc, QEMU_OPTION_hdd, + QEMU_OPTION_disk, QEMU_OPTION_cdrom, QEMU_OPTION_mtdblock, QEMU_OPTION_sd, @@ -7302,6 +7413,7 @@ const QEMUOption qemu_options[] = { { "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 }, @@ -7629,7 +7741,7 @@ int main(int argc, char **argv) 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; @@ -7637,9 +7749,12 @@ int main(int argc, char **argv) DisplayState *ds = &display_state; int cyls, heads, secs, translation; char net_clients[MAX_NET_CLIENTS][256]; + char disks[MAX_DISKS][256]; char cdroms[MAX_CDROMS][256]; int nb_net_clients; + int nb_disks; int nb_cdroms; + int hda_index = -1; int optind; const char *r, *optarg; CharDriverState *monitor_hd; @@ -7694,8 +7809,6 @@ int main(int argc, char **argv) initrd_filename = NULL; for(i = 0; i < MAX_FD; i++) fd_filename[i] = NULL; - for(i = 0; i < MAX_DISKS; i++) - hd_filename[i] = NULL; for(i = 0; i < MAX_PFLASH; i++) pflash_filename[i] = NULL; pflash_index = 0; @@ -7728,6 +7841,7 @@ int main(int argc, char **argv) usb_devices_index = 0; nb_net_clients = 0; + nb_disks = 0; nb_cdroms = 0; nb_nics = 0; @@ -7739,7 +7853,10 @@ int main(int argc, char **argv) break; r = argv[optind]; if (r[0] != '-') { - hd_filename[0] = argv[optind++]; + hda_index = nb_disks; + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s,bus=0,unit=0", argv[optind++]); + nb_disks++; } else { const QEMUOption *popt; @@ -7799,15 +7916,51 @@ int main(int argc, char **argv) initrd_filename = optarg; break; case QEMU_OPTION_hda: + if (nb_disks >= MAX_DISKS) { + fprintf(stderr, "qemu: too many disks\n"); + exit(1); + } + hda_index = nb_disks; + if (cyls == 0) + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s,bus=0,unit=0", optarg); + else { + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s,bus=0,unit=0,cyls=%d,heads=%d,secs=%d%s", + optarg, cyls, heads, secs, + translation == BIOS_ATA_TRANSLATION_LBA ? + ",trans=lba" : + translation == BIOS_ATA_TRANSLATION_NONE ? + ",trans=none" : ""); + } + nb_disks++; + break; case QEMU_OPTION_hdb: case QEMU_OPTION_hdc: case QEMU_OPTION_hdd: { int hd_index; + if (nb_disks >= MAX_DISKS) { + fprintf(stderr, "qemu: too many disks\n"); + exit(1); + } hd_index = popt->index - QEMU_OPTION_hda; - hd_filename[hd_index] = optarg; + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s,bus=%d,unit=%d", optarg, + hd_index / 2, hd_index % 2); + nb_disks++; } break; + case QEMU_OPTION_disk: + if (nb_disks >= 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 = optarg; break; @@ -7858,6 +8011,15 @@ int main(int argc, char **argv) fprintf(stderr, "qemu: invalid physical CHS format\n"); exit(1); } + if (hda_index != -1) + snprintf(disks[hda_index] + strlen(disks[hda_index]), + sizeof(disks[0]) - strlen(disks[hda_index]), + ",cyls=%d,heads=%d,secs=%d%s", + cyls, heads, secs, + translation == BIOS_ATA_TRANSLATION_LBA ? + ",trans=lba" : + translation == BIOS_ATA_TRANSLATION_NONE ? + ",trans=none" : ""); } break; case QEMU_OPTION_nographic: @@ -8245,13 +8407,13 @@ int main(int argc, char **argv) if (!linux_boot && boot_device != 'n' && - hd_filename[0] == '\0' && + nb_disks == 0 && (nb_cdroms >= 0 && cdroms[0] == '\0') && fd_filename[0] == '\0') help(1); /* boot to floppy or the default cd if no hard disk defined yet */ - if (hd_filename[0] == '\0' && boot_device == 'c') { + if (nb_disks == 0 && boot_device == 'c') { if (fd_filename[0] != '\0') boot_device = 'a'; else @@ -8337,23 +8499,10 @@ int main(int argc, char **argv) exit(1); /* open the virtual block devices */ - for(i = 0; i < MAX_DISKS; i++) { - if (hd_filename[i]) { - char buf[64]; - snprintf(buf, sizeof(buf), "hd%c", i + 'a'); - bs_table[i] = bdrv_new(buf); - - if (bdrv_open(bs_table[i], hd_filename[i], snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { - fprintf(stderr, "qemu: could not open hard disk image '%s'\n", - hd_filename[i]); - exit(1); - } - if (i == 0 && cyls != 0) { - bdrv_set_geometry_hint(bs_table[i], cyls, heads, secs); - bdrv_set_translation_hint(bs_table[i], translation); - } - } - } + + for(i = 0; i < nb_disks; i++) + if (disk_init(disks[i], snapshot) == -1) + exit(1); /* we always create at least one floppy disk */ fd_table[0] = bdrv_new("fda"); -- 1.4.4.4 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 3/3] Add scsi support to pc target 2007-10-28 22:43 ` [Qemu-devel] [PATCH 2/3] Add arg -disk to define new disk with more features Laurent.Vivier @ 2007-10-28 22:43 ` Laurent.Vivier 0 siblings, 0 replies; 27+ messages in thread From: Laurent.Vivier @ 2007-10-28 22:43 UTC (permalink / raw) To: qemu-devel From: Laurent Vivier <vivierl@frecb07144.(none)> This patch add the support of SCSI disk and cdrom for PC target, using previously introduced parameters "-disk" and "-cdrom". For the momemt, it supports only one bus, but more can be added easily. --- hw/lsi53c895a.c | 3 -- hw/pc.c | 16 ++-------- hw/realview.c | 6 ++-- hw/versatilepb.c | 6 ++-- vl.c | 83 +++++++++++++++++++++++++++++++++++++++++++++-------- vl.h | 7 ++++- 6 files changed, 86 insertions(+), 35 deletions(-) diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index e9866ba..98413d5 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -149,9 +149,6 @@ do { fprintf(stderr, "lsi_scsi: error: " fmt , ##args);} while (0) #define PHASE_MI 7 #define PHASE_MASK 7 -/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ -#define LSI_MAX_DEVS 7 - /* Maximum length of MSG IN data. */ #define LSI_MAX_MSGIN_LEN 8 diff --git a/hw/pc.c b/hw/pc.c index c561cbf..a8898eb 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -921,23 +921,15 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, if (i440fx_state) { i440fx_init_memory_mappings(i440fx_state); } -#if 0 - /* ??? Need to figure out some way for the user to - specify SCSI devices. */ + if (pci_enabled) { void *scsi; - BlockDriverState *bdrv; scsi = lsi_scsi_init(pci_bus, -1); - bdrv = bdrv_new("scsidisk"); - bdrv_open(bdrv, "scsi_disk.img", 0); - lsi_scsi_attach(scsi, bdrv, -1); - bdrv = bdrv_new("scsicd"); - bdrv_open(bdrv, "scsi_cd.iso", 0); - bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM); - lsi_scsi_attach(scsi, bdrv, -1); + for (i = 0; i < LSI_MAX_DEVS; i++) + if (bs_table[MAX_DISKS + i]) + lsi_scsi_attach(scsi, bs_table[MAX_DISKS + i], i); } -#endif } static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device, diff --git a/hw/realview.c b/hw/realview.c index 375f78a..e091cbb 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -64,9 +64,9 @@ static void realview_init(int ram_size, int vga_ram_size, int boot_device, usb_ohci_init_pci(pci_bus, 3, -1); } scsi_hba = lsi_scsi_init(pci_bus, -1); - for (n = 0; n < MAX_DISKS; n++) { - if (bs_table[n]) { - lsi_scsi_attach(scsi_hba, bs_table[n], n); + for (n = 0; n < LSI_MAX_DEVS; n++) { + if (bs_table[MAX_DISKS + n]) { + lsi_scsi_attach(scsi_hba, bs_table[MAX_DISKS + n], n); } } for(n = 0; n < nb_nics; n++) { diff --git a/hw/versatilepb.c b/hw/versatilepb.c index 2e3dedd..fbbe989 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -198,9 +198,9 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device, usb_ohci_init_pci(pci_bus, 3, -1); } scsi_hba = lsi_scsi_init(pci_bus, -1); - for (n = 0; n < MAX_DISKS; n++) { - if (bs_table[n]) { - lsi_scsi_attach(scsi_hba, bs_table[n], n); + for (n = 0; n < LSI_MAX_DEVS; n++) { + if (bs_table[MAX_DISKS + n]) { + lsi_scsi_attach(scsi_hba, bs_table[MAX_DISKS + n], n); } } diff --git a/vl.c b/vl.c index 8408ce4..d5b0738 100644 --- a/vl.c +++ b/vl.c @@ -149,9 +149,9 @@ char phys_ram_file[1024]; 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_DISKS + LSI_MAX_DEVS] 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_DISKS + LSI_MAX_DEVS + 1], *fd_table[MAX_FD]; BlockDriverState *pflash_table[MAX_PFLASH]; BlockDriverState *sd_bdrv; BlockDriverState *mtd_bdrv; @@ -4701,6 +4701,16 @@ void do_info_network(void) } } +#if defined(TARGET_ARM) +#define DEFAULT_DISK_BUS 0 +#define DEFAULT_DISK_UNIT 0 +#define DEFAULT_DISK_IF "scsi" +#else +#define DEFAULT_DISK_BUS 0 +#define DEFAULT_DISK_UNIT 0 +#define DEFAULT_DISK_IF "ide" +#endif + static int disk_init(const char *str, int snapshot) { char buf[16]; @@ -4723,7 +4733,7 @@ static int disk_init(const char *str, int snapshot) bus_id = -1; unit_id = -1; translation = BIOS_ATA_TRANSLATION_AUTO; - pstrcpy(interface, sizeof(interface), "ide"); + pstrcpy(interface, sizeof(interface), DEFAULT_DISK_IF); if (get_param_value(buf, sizeof(buf), "bus", p)) { bus_id = strtol(buf, NULL, 0); @@ -4770,7 +4780,7 @@ static int disk_init(const char *str, int snapshot) } if (strcmp(interface, "ide") == 0) { - static int disk_index = -1; + static int disk_index = DEFAULT_DISK_BUS * 2 + DEFAULT_DISK_UNIT - 1; disk_index++; @@ -4801,7 +4811,33 @@ static int disk_init(const char *str, int snapshot) } return 0; } else if (strcmp(interface, "scsi") == 0) { - /* TODO */ + static int disk_index = DEFAULT_DISK_BUS * LSI_MAX_DEVS + DEFAULT_DISK_UNIT - 1; + + disk_index++; + + if (bus_id == -1) { + bus_id = disk_index / LSI_MAX_DEVS; + if (unit_id == -1) + unit_id = disk_index % LSI_MAX_DEVS; + } else if (unit_id == -1) + unit_id = 0; + + disk_index = bus_id * LSI_MAX_DEVS + unit_id; + + snprintf(buf, sizeof(buf), "sd%c", disk_index + 'a'); + + disk_index += MAX_DISKS; + + bs_table[disk_index] = bdrv_new(buf); + + if (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; + } + + return 0; } fprintf(stderr, "unsupported bus type '%s' for cdrom '%s'\n", @@ -4809,12 +4845,18 @@ static int disk_init(const char *str, int snapshot) return -1; } +#if defined(TARGET_PPC) #define MAX_CDROMS 4 -#ifdef TARGET_PPC #define DEFAULT_CDROM_BUS 0 #define DEFAULT_CDROM_UNIT 1 #define DEFAULT_CDROM_IF "ide" +#elif defined(TARGET_ARM) +#define MAX_CDROMS 7 +#define DEFAULT_CDROM_BUS 0 +#define DEFAULT_CDROM_UNIT 3 +#define DEFAULT_CDROM_IF "scsi" #else +#define MAX_CDROMS 4 #define DEFAULT_CDROM_BUS 1 #define DEFAULT_CDROM_UNIT 0 #define DEFAULT_CDROM_IF "ide" @@ -4874,7 +4916,21 @@ static int cdrom_init(const char *str) } return 0; } else if (strcmp(interface, "scsi") == 0) { - /* TODO */ + int cdrom_index = bus_id * LSI_MAX_DEVS + unit_id; + + snprintf(buf, sizeof(buf), "sd%c", cdrom_index + 'a'); + + cdrom_index += MAX_DISKS; + bs_table[cdrom_index] = bdrv_new(buf); + bdrv_set_type_hint(bs_table[cdrom_index], BDRV_TYPE_CDROM); + + if (bdrv_open(bs_table[cdrom_index], file, 0) < 0) { + fprintf(stderr, "qemu: could not open hard disk image '%s'\n", + file); + return -1; + } + + return 0; } fprintf(stderr, "unsupported bus type '%s' for cdrom '%s'\n", @@ -7855,7 +7911,7 @@ int main(int argc, char **argv) if (r[0] != '-') { hda_index = nb_disks; snprintf(disks[nb_disks], sizeof(disks[0]), - "%s,bus=0,unit=0", argv[optind++]); + "%s,bus=0,unit=0,if=%s", argv[optind++], DEFAULT_DISK_IF); nb_disks++; } else { const QEMUOption *popt; @@ -7923,11 +7979,11 @@ int main(int argc, char **argv) hda_index = nb_disks; if (cyls == 0) snprintf(disks[nb_disks], sizeof(disks[0]), - "%s,bus=0,unit=0", optarg); + "%s,bus=0,unit=0,if=%s", optarg, DEFAULT_DISK_IF); else { snprintf(disks[nb_disks], sizeof(disks[0]), - "%s,bus=0,unit=0,cyls=%d,heads=%d,secs=%d%s", - optarg, cyls, heads, secs, + "%s,bus=0,unit=0,if=%s,cyls=%d,heads=%d,secs=%d%s", + optarg, DEFAULT_DISK_IF, cyls, heads, secs, translation == BIOS_ATA_TRANSLATION_LBA ? ",trans=lba" : translation == BIOS_ATA_TRANSLATION_NONE ? @@ -7946,8 +8002,9 @@ int main(int argc, char **argv) } hd_index = popt->index - QEMU_OPTION_hda; snprintf(disks[nb_disks], sizeof(disks[0]), - "%s,bus=%d,unit=%d", optarg, - hd_index / 2, hd_index % 2); + "%s,bus=%d,unit=%d,if=%s", optarg, + hd_index / 2, hd_index % 2, + DEFAULT_DISK_IF); nb_disks++; } break; diff --git a/vl.h b/vl.h index 681dd91..0646b3c 100644 --- a/vl.h +++ b/vl.h @@ -989,10 +989,15 @@ void do_info_vnc(void); /* x_keymap.c */ extern uint8_t _translate_keycode(const int key); +/* lsi53c895a.c */ + +/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ +#define LSI_MAX_DEVS 7 + /* ide.c */ #define MAX_DISKS 4 -extern BlockDriverState *bs_table[MAX_DISKS + 1]; +extern BlockDriverState *bs_table[MAX_DISKS + LSI_MAX_DEVS + 1]; extern BlockDriverState *sd_bdrv; extern BlockDriverState *mtd_bdrv; -- 1.4.4.4 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-28 22:43 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 2/3] Add arg -disk to define new disk with more features Laurent.Vivier @ 2007-10-29 12:03 ` Johannes Schindelin 2007-10-29 12:36 ` Laurent Vivier 2007-10-29 13:25 ` Daniel P. Berrange 2 siblings, 1 reply; 27+ messages in thread From: Johannes Schindelin @ 2007-10-29 12:03 UTC (permalink / raw) To: Laurent.Vivier; +Cc: qemu-devel Hi Laurent, I could not apply your patches, because they assumed that there are mtd and pflash devices. So I fixed them and pushed them to http://repo.or.cz/w/qemu/dscho.git/, branch "scsi" for your viewing pleasure. Note: since I only have gcc4, I could not even compile test. Ciao, Dscho ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 12:03 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Johannes Schindelin @ 2007-10-29 12:36 ` Laurent Vivier 0 siblings, 0 replies; 27+ messages in thread From: Laurent Vivier @ 2007-10-29 12:36 UTC (permalink / raw) To: qemu-devel Johannes Schindelin a écrit : > Hi Laurent, Hi Johannes, > I could not apply your patches, because they assumed that there are mtd > and pflash devices. well, perhaps I didn't take the good repository... > So I fixed them and pushed them to http://repo.or.cz/w/qemu/dscho.git/, > branch "scsi" for your viewing pleasure. Note: since I only have gcc4, I > could not even compile test. OK, thank you for your help. Is there someone that can say if it's really interesting and included in qemu CVS ? Laurent -- ---------------- Laurent.Vivier@bull.net ----------------- "Given enough eyeballs, all bugs are shallow" E. S. Raymond ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-28 22:43 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 2/3] Add arg -disk to define new disk with more features Laurent.Vivier 2007-10-29 12:03 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Johannes Schindelin @ 2007-10-29 13:25 ` Daniel P. Berrange 2007-10-29 14:02 ` Laurent Vivier 2007-10-29 14:49 ` andrzej zaborowski 2 siblings, 2 replies; 27+ messages in thread From: Daniel P. Berrange @ 2007-10-29 13:25 UTC (permalink / raw) To: qemu-devel On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: > From: Laurent Vivier <vivierl@frecb07144.(none)> > > This patch allows to define where is connected the CDROM device (bus, > unit). > It extends the "-cdrom" syntax to add these paramaters: > > -cdrom file[,if=type][,bus=n][,unit=m] > > where "type" defines the interface (by default, "ide") > "n" defines the bus number (by default 1) > "m" defines the unit number (by default 0) Having a separately named arg just for CDROMs was always rather odd/unhelpful. I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc unchanged and use the -disk for setting up all types of disks, floppys, cdroms, etc. It would just require one extra field for the -disk arg: -disk file[,if=type][,bus=n][,unit=m][,mode=mode] where "type" defines the interface. [ide,scsi,fd] (by default, "ide") "n" defines the bus number (by default 1) "m" defines the unit number (by default 0) "mode" defines one of [disk,floppy,cdrom] If we ever up able to emulate other types of SCSI / IDE devices (tape drives, cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=| ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 13:25 ` Daniel P. Berrange @ 2007-10-29 14:02 ` Laurent Vivier 2007-10-29 14:07 ` risc 2007-10-29 14:34 ` Thiemo Seufer 2007-10-29 14:49 ` andrzej zaborowski 1 sibling, 2 replies; 27+ messages in thread From: Laurent Vivier @ 2007-10-29 14:02 UTC (permalink / raw) To: Daniel P. Berrange, qemu-devel Daniel P. Berrange a écrit : > On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: >> From: Laurent Vivier <vivierl@frecb07144.(none)> >> >> This patch allows to define where is connected the CDROM device (bus, >> unit). >> It extends the "-cdrom" syntax to add these paramaters: >> >> -cdrom file[,if=type][,bus=n][,unit=m] >> >> where "type" defines the interface (by default, "ide") >> "n" defines the bus number (by default 1) >> "m" defines the unit number (by default 0) > > > Having a separately named arg just for CDROMs was always rather odd/unhelpful. > I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc unchanged > and use the -disk for setting up all types of disks, floppys, cdroms, etc. It > would just require one extra field for the -disk arg: > > -disk file[,if=type][,bus=n][,unit=m][,mode=mode] > > where "type" defines the interface. [ide,scsi,fd] (by default, "ide") > "n" defines the bus number (by default 1) > "m" defines the unit number (by default 0) > "mode" defines one of [disk,floppy,cdrom] > > If we ever up able to emulate other types of SCSI / IDE devices (tape drives, > cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. I agree with that. And if everyone agrees I can modify patches to do that... Laurent -- ---------------- Laurent.Vivier@bull.net ----------------- "Given enough eyeballs, all bugs are shallow" E. S. Raymond ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 14:02 ` Laurent Vivier @ 2007-10-29 14:07 ` risc 2007-10-29 14:54 ` Markus Hitter 2007-10-29 15:46 ` Laurent Vivier 2007-10-29 14:34 ` Thiemo Seufer 1 sibling, 2 replies; 27+ messages in thread From: risc @ 2007-10-29 14:07 UTC (permalink / raw) To: qemu-devel On Mon, Oct 29, 2007 at 03:02:21PM +0100, Laurent Vivier wrote: > Daniel P. Berrange a écrit : > >On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: > >>From: Laurent Vivier <vivierl@frecb07144.(none)> > >> > >>This patch allows to define where is connected the CDROM device (bus, > >>unit). > >>It extends the "-cdrom" syntax to add these paramaters: > >> > >> -cdrom file[,if=type][,bus=n][,unit=m] > >> > >> where "type" defines the interface (by default, "ide") > >> "n" defines the bus number (by default 1) > >> "m" defines the unit number (by default 0) > > > > > >Having a separately named arg just for CDROMs was always rather > >odd/unhelpful. > >I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc > >unchanged > >and use the -disk for setting up all types of disks, floppys, cdroms, etc. > >It > >would just require one extra field for the -disk arg: > > > > -disk file[,if=type][,bus=n][,unit=m][,mode=mode] > > > > where "type" defines the interface. [ide,scsi,fd] (by default, "ide") > > "n" defines the bus number (by default 1) > > "m" defines the unit number (by default 0) > > "mode" defines one of [disk,floppy,cdrom] > > > >If we ever up able to emulate other types of SCSI / IDE devices (tape > >drives, > >cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. > > I agree with that. And if everyone agrees I can modify patches to do that... > > Laurent > -- > ---------------- Laurent.Vivier@bull.net ----------------- > "Given enough eyeballs, all bugs are shallow" E. S. Raymond > > > not to be rude, but "my" version of the scsi patch supports three controllers, for a total of 21 disks. might i reccomend you impliment -disk with a controller, bus, target syntax, ALA sun? Julia Longtin <risc@volumehost.com> ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 14:07 ` risc @ 2007-10-29 14:54 ` Markus Hitter 2007-10-29 15:46 ` Laurent Vivier 1 sibling, 0 replies; 27+ messages in thread From: Markus Hitter @ 2007-10-29 14:54 UTC (permalink / raw) To: qemu-devel Am 29.10.2007 um 15:07 schrieb risc@volumehost.com: > On Mon, Oct 29, 2007 at 03:02:21PM +0100, Laurent Vivier wrote: >> Daniel P. Berrange a écrit : >>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc >>> unchanged >>> and use the -disk for setting up all types of disks, floppys, >>> cdroms, etc. >>> It >>> would just require one extra field for the -disk arg: >>> >>> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] >>> >>> where "type" defines the interface. [ide,scsi,fd] (by default, >>> "ide") >>> "n" defines the bus number (by default 1) >>> "m" defines the unit number (by default 0) >>> "mode" defines one of [disk,floppy,cdrom] >>> >> I agree with that. And if everyone agrees I can modify patches to >> do that... >> >> Laurent >> > not to be rude, but "my" version of the scsi patch supports three > controllers, > for a total of 21 disks. might i reccomend you impliment -disk with > a controller, > bus, target syntax, ALA sun? Would it be possible to use isa's bus number to describe an scsi controller? If you have controllers with two buses, talk to them like two distinct controllers. Markus - - - - - - - - - - - - - - - - - - - Dipl. Ing. Markus Hitter http://www.jump-ing.de/ ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 14:07 ` risc 2007-10-29 14:54 ` Markus Hitter @ 2007-10-29 15:46 ` Laurent Vivier 2007-10-29 17:23 ` Blue Swirl 1 sibling, 1 reply; 27+ messages in thread From: Laurent Vivier @ 2007-10-29 15:46 UTC (permalink / raw) To: qemu-devel risc@volumehost.com a écrit : > On Mon, Oct 29, 2007 at 03:02:21PM +0100, Laurent Vivier wrote: >> Daniel P. Berrange a écrit : >>> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: >>>> From: Laurent Vivier <vivierl@frecb07144.(none)> >>>> >>>> This patch allows to define where is connected the CDROM device (bus, >>>> unit). >>>> It extends the "-cdrom" syntax to add these paramaters: >>>> >>>> -cdrom file[,if=type][,bus=n][,unit=m] >>>> >>>> where "type" defines the interface (by default, "ide") >>>> "n" defines the bus number (by default 1) >>>> "m" defines the unit number (by default 0) >>> >>> Having a separately named arg just for CDROMs was always rather >>> odd/unhelpful. >>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc >>> unchanged >>> and use the -disk for setting up all types of disks, floppys, cdroms, etc. >>> It >>> would just require one extra field for the -disk arg: >>> >>> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] >>> >>> where "type" defines the interface. [ide,scsi,fd] (by default, "ide") >>> "n" defines the bus number (by default 1) >>> "m" defines the unit number (by default 0) >>> "mode" defines one of [disk,floppy,cdrom] >>> >>> If we ever up able to emulate other types of SCSI / IDE devices (tape >>> drives, >>> cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. >> I agree with that. And if everyone agrees I can modify patches to do that... >> >> Laurent >> -- >> ---------------- Laurent.Vivier@bull.net ----------------- >> "Given enough eyeballs, all bugs are shallow" E. S. Raymond >> >> >> > not to be rude, but "my" version of the scsi patch supports three controllers, > for a total of 21 disks. might i reccomend you impliment -disk with a controller, > bus, target syntax, ALA sun? Well, IMHO, bus number should be enough, because the bus identify the controller... but we can discuss that later, as the syntax allows to add easily a "controller" arg to "-disk". Laurent -- ---------------- Laurent.Vivier@bull.net ----------------- "Given enough eyeballs, all bugs are shallow" E. S. Raymond ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 15:46 ` Laurent Vivier @ 2007-10-29 17:23 ` Blue Swirl 0 siblings, 0 replies; 27+ messages in thread From: Blue Swirl @ 2007-10-29 17:23 UTC (permalink / raw) To: qemu-devel On 10/29/07, Laurent Vivier <Laurent.Vivier@bull.net> wrote: > risc@volumehost.com a écrit : > > On Mon, Oct 29, 2007 at 03:02:21PM +0100, Laurent Vivier wrote: > >> Daniel P. Berrange a écrit : > >>> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: > >>>> From: Laurent Vivier <vivierl@frecb07144.(none)> > >>>> > >>>> This patch allows to define where is connected the CDROM device (bus, > >>>> unit). > >>>> It extends the "-cdrom" syntax to add these paramaters: > >>>> > >>>> -cdrom file[,if=type][,bus=n][,unit=m] > >>>> > >>>> where "type" defines the interface (by default, "ide") > >>>> "n" defines the bus number (by default 1) > >>>> "m" defines the unit number (by default 0) > >>> > >>> Having a separately named arg just for CDROMs was always rather > >>> odd/unhelpful. > >>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc > >>> unchanged > >>> and use the -disk for setting up all types of disks, floppys, cdroms, etc. > >>> It > >>> would just require one extra field for the -disk arg: > >>> > >>> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] > >>> > >>> where "type" defines the interface. [ide,scsi,fd] (by default, "ide") > >>> "n" defines the bus number (by default 1) > >>> "m" defines the unit number (by default 0) > >>> "mode" defines one of [disk,floppy,cdrom] > >>> > >>> If we ever up able to emulate other types of SCSI / IDE devices (tape > >>> drives, > >>> cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. > >> I agree with that. And if everyone agrees I can modify patches to do that... > >> > >> Laurent > >> -- > >> ---------------- Laurent.Vivier@bull.net ----------------- > >> "Given enough eyeballs, all bugs are shallow" E. S. Raymond > >> > >> > >> > > not to be rude, but "my" version of the scsi patch supports three controllers, > > for a total of 21 disks. might i reccomend you impliment -disk with a controller, > > bus, target syntax, ALA sun? > > Well, IMHO, bus number should be enough, because the bus identify the > controller... but we can discuss that later, as the syntax allows to add easily > a "controller" arg to "-disk". And also "lun"? ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 14:02 ` Laurent Vivier 2007-10-29 14:07 ` risc @ 2007-10-29 14:34 ` Thiemo Seufer 2007-11-02 13:24 ` Laurent Vivier 1 sibling, 1 reply; 27+ messages in thread From: Thiemo Seufer @ 2007-10-29 14:34 UTC (permalink / raw) To: Laurent Vivier; +Cc: qemu-devel Laurent Vivier wrote: > Daniel P. Berrange a écrit : >> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: >>> From: Laurent Vivier <vivierl@frecb07144.(none)> >>> >>> This patch allows to define where is connected the CDROM device (bus, >>> unit). >>> It extends the "-cdrom" syntax to add these paramaters: >>> >>> -cdrom file[,if=type][,bus=n][,unit=m] >>> >>> where "type" defines the interface (by default, "ide") >>> "n" defines the bus number (by default 1) >>> "m" defines the unit number (by default 0) >> Having a separately named arg just for CDROMs was always rather >> odd/unhelpful. >> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc >> unchanged >> and use the -disk for setting up all types of disks, floppys, cdroms, etc. >> It >> would just require one extra field for the -disk arg: >> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] >> where "type" defines the interface. [ide,scsi,fd] (by default, "ide") >> "n" defines the bus number (by default 1) >> "m" defines the unit number (by default 0) >> "mode" defines one of [disk,floppy,cdrom] >> If we ever up able to emulate other types of SCSI / IDE devices (tape >> drives, >> cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. > > I agree with that. And if everyone agrees I can modify patches to do > that... Please go ahead. :-) Thiemo ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 14:34 ` Thiemo Seufer @ 2007-11-02 13:24 ` Laurent Vivier 2007-11-07 23:32 ` Fabrice Bellard 0 siblings, 1 reply; 27+ messages in thread From: Laurent Vivier @ 2007-11-02 13:24 UTC (permalink / raw) To: Thiemo Seufer; +Cc: qemu-devel Thiemo Seufer a écrit : > Laurent Vivier wrote: >> Daniel P. Berrange a écrit : >>> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: >>>> From: Laurent Vivier <vivierl@frecb07144.(none)> >>>> >>>> This patch allows to define where is connected the CDROM device (bus, >>>> unit). >>>> It extends the "-cdrom" syntax to add these paramaters: >>>> >>>> -cdrom file[,if=type][,bus=n][,unit=m] >>>> >>>> where "type" defines the interface (by default, "ide") >>>> "n" defines the bus number (by default 1) >>>> "m" defines the unit number (by default 0) >>> Having a separately named arg just for CDROMs was always rather >>> odd/unhelpful. >>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc >>> unchanged >>> and use the -disk for setting up all types of disks, floppys, cdroms, etc. >>> It >>> would just require one extra field for the -disk arg: >>> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] >>> where "type" defines the interface. [ide,scsi,fd] (by default, "ide") >>> "n" defines the bus number (by default 1) >>> "m" defines the unit number (by default 0) >>> "mode" defines one of [disk,floppy,cdrom] >>> If we ever up able to emulate other types of SCSI / IDE devices (tape >>> drives, >>> cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. >> I agree with that. And if everyone agrees I can modify patches to do >> that... > > Please go ahead. :-) Well, it is done... is there someone that can comment them ? Or if they are perfect (as usual ;-) ) perhaps it could be included in CVS ? Regards, Laurent -- ---------------- Laurent.Vivier@bull.net ----------------- "Given enough eyeballs, all bugs are shallow" E. S. Raymond ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-11-02 13:24 ` Laurent Vivier @ 2007-11-07 23:32 ` Fabrice Bellard 2007-11-08 9:02 ` Laurent Vivier 2007-11-10 0:02 ` Laurent Vivier 0 siblings, 2 replies; 27+ messages in thread From: Fabrice Bellard @ 2007-11-07 23:32 UTC (permalink / raw) To: qemu-devel; +Cc: Laurent.Vivier Laurent Vivier wrote: > Thiemo Seufer a écrit : >> Laurent Vivier wrote: >>> Daniel P. Berrange a écrit : >>>> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net >>>> wrote: >>>>> From: Laurent Vivier <vivierl@frecb07144.(none)> >>>>> >>>>> This patch allows to define where is connected the CDROM device (bus, >>>>> unit). >>>>> It extends the "-cdrom" syntax to add these paramaters: >>>>> >>>>> -cdrom file[,if=type][,bus=n][,unit=m] >>>>> >>>>> where "type" defines the interface (by default, "ide") >>>>> "n" defines the bus number (by default 1) >>>>> "m" defines the unit number (by default 0) >>>> Having a separately named arg just for CDROMs was always rather >>>> odd/unhelpful. >>>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc >>>> unchanged >>>> and use the -disk for setting up all types of disks, floppys, >>>> cdroms, etc. It >>>> would just require one extra field for the -disk arg: >>>> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] >>>> where "type" defines the interface. [ide,scsi,fd] (by default, >>>> "ide") >>>> "n" defines the bus number (by default 1) >>>> "m" defines the unit number (by default 0) >>>> "mode" defines one of [disk,floppy,cdrom] >>>> If we ever up able to emulate other types of SCSI / IDE devices >>>> (tape drives, >>>> cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. >>> I agree with that. And if everyone agrees I can modify patches to do >>> that... >> >> Please go ahead. :-) > > Well, it is done... is there someone that can comment them ? > Or if they are perfect (as usual ;-) ) perhaps it could be included in > CVS ? I had rejected a similar patch in the past, but I agree that a -disk command line option is needed. A few remarks: - Add a function in vl.c to add a disk so that all option handlers can call it instead of doing pstrcpy(); nb_disk++. - You replaced the constant "2" in many machines by MAX_IDE_BUS. It is dangerous because each machine has its own constraints. - Maybe the real option name could be "-drive" to insist on the fact that a drive can be created without a disk in it ! Any more comments ? - disk_init() should not modify its argument str. Moreover, maybe having an explicit "file=" argument would be clearer in the case there is no disk in the drive. - While modifying the machine init function, you can suppress the snapshot parameter. - In disk_init(), you should factorize the bdrv_new() and bdrv_open() as it is the same for all types. - It could be simpler to export an array of structs containg a bdrv, each one tagged with if, index and bus. Then each machine could call a function to get the bdrv from the parameters "if", "index" and "bus". For example, look at the NICInfo structure and do the same with a structure DriveInfo... If you prefer, you can resubmit a big patch with all the changes. Regards, Fabrice. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-11-07 23:32 ` Fabrice Bellard @ 2007-11-08 9:02 ` Laurent Vivier 2007-11-08 9:33 ` Fabrice Bellard 2007-11-10 0:02 ` Laurent Vivier 1 sibling, 1 reply; 27+ messages in thread From: Laurent Vivier @ 2007-11-08 9:02 UTC (permalink / raw) To: Fabrice Bellard; +Cc: qemu-devel [-- Attachment #1: Type: text/plain, Size: 4117 bytes --] Le jeudi 08 novembre 2007 à 00:32 +0100, Fabrice Bellard a écrit : > Laurent Vivier wrote: > > Thiemo Seufer a écrit : > >> Laurent Vivier wrote: > >>> Daniel P. Berrange a écrit : > >>>> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net > >>>> wrote: > >>>>> From: Laurent Vivier <vivierl@frecb07144.(none)> > >>>>> > >>>>> This patch allows to define where is connected the CDROM device (bus, > >>>>> unit). > >>>>> It extends the "-cdrom" syntax to add these paramaters: > >>>>> > >>>>> -cdrom file[,if=type][,bus=n][,unit=m] > >>>>> > >>>>> where "type" defines the interface (by default, "ide") > >>>>> "n" defines the bus number (by default 1) > >>>>> "m" defines the unit number (by default 0) > >>>> Having a separately named arg just for CDROMs was always rather > >>>> odd/unhelpful. > >>>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc > >>>> unchanged > >>>> and use the -disk for setting up all types of disks, floppys, > >>>> cdroms, etc. It > >>>> would just require one extra field for the -disk arg: > >>>> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] > >>>> where "type" defines the interface. [ide,scsi,fd] (by default, > >>>> "ide") > >>>> "n" defines the bus number (by default 1) > >>>> "m" defines the unit number (by default 0) > >>>> "mode" defines one of [disk,floppy,cdrom] > >>>> If we ever up able to emulate other types of SCSI / IDE devices > >>>> (tape drives, > >>>> cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. > >>> I agree with that. And if everyone agrees I can modify patches to do > >>> that... > >> > >> Please go ahead. :-) > > > > Well, it is done... is there someone that can comment them ? > > Or if they are perfect (as usual ;-) ) perhaps it could be included in > > CVS ? > > I had rejected a similar patch in the past, but I agree that a -disk > command line option is needed. > > A few remarks: > > - Add a function in vl.c to add a disk so that all option handlers can > call it instead of doing pstrcpy(); nb_disk++. I agree > - You replaced the constant "2" in many machines by MAX_IDE_BUS. It is > dangerous because each machine has its own constraints. I agree, I'll use MAX_IDE_BUS only for PC. But how can I compute MAX_DISKS if the number of IDE disks vary with target ? For the moment it is the sum of all available MAX_* . Should I take an explicit value like "32" or something like ? > > - Maybe the real option name could be "-drive" to insist on the fact > that a drive can be created without a disk in it ! Any more comments ? I agree, and a drive can be something else like a flash or a tape (in the future...). > - disk_init() should not modify its argument str. Moreover, maybe having > an explicit "file=" argument would be clearer in the case there is no > disk in the drive. I'm not sure I understand correctly this one. For the moment "-disk ," allows to declare a drive without media (an empty CDROM drive, for instance). Do you mean we must use "-drive file=a.img" instead of "-disk a.img" and "-drive file=" instead of "-disk ," > - While modifying the machine init function, you can suppress the > snapshot parameter. OK > - In disk_init(), you should factorize the bdrv_new() and bdrv_open() as > it is the same for all types. OK. Can I use bdrv_set_geometry_hint() and bdrv_set_translation_hint() before the bdrv_open() ? > > - It could be simpler to export an array of structs containg a bdrv, > each one tagged with if, index and bus. Then each machine could call a > function to get the bdrv from the parameters "if", "index" and "bus". > For example, look at the NICInfo structure and do the same with a > structure DriveInfo... OK > If you prefer, you can resubmit a big patch with all the changes. Well, I like to write a lot of little patches ;-) It is easier to review them, isn't it ? But it is as you want. > Regards, > > Fabrice. Thank you for your comments, Laurent [-- Attachment #2: Ceci est une partie de message numériquement signée --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-11-08 9:02 ` Laurent Vivier @ 2007-11-08 9:33 ` Fabrice Bellard 0 siblings, 0 replies; 27+ messages in thread From: Fabrice Bellard @ 2007-11-08 9:33 UTC (permalink / raw) To: qemu-devel Laurent Vivier wrote: > Le jeudi 08 novembre 2007 à 00:32 +0100, Fabrice Bellard a écrit : >> Laurent Vivier wrote: >>> Thiemo Seufer a écrit : >>>> Laurent Vivier wrote: >>>>> Daniel P. Berrange a écrit : >>>>>> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net >>>>>> wrote: >>>>>>> From: Laurent Vivier <vivierl@frecb07144.(none)> >>>>>>> >>>>>>> This patch allows to define where is connected the CDROM device (bus, >>>>>>> unit). >>>>>>> It extends the "-cdrom" syntax to add these paramaters: >>>>>>> >>>>>>> -cdrom file[,if=type][,bus=n][,unit=m] >>>>>>> >>>>>>> where "type" defines the interface (by default, "ide") >>>>>>> "n" defines the bus number (by default 1) >>>>>>> "m" defines the unit number (by default 0) >>>>>> Having a separately named arg just for CDROMs was always rather >>>>>> odd/unhelpful. >>>>>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc >>>>>> unchanged >>>>>> and use the -disk for setting up all types of disks, floppys, >>>>>> cdroms, etc. It >>>>>> would just require one extra field for the -disk arg: >>>>>> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] >>>>>> where "type" defines the interface. [ide,scsi,fd] (by default, >>>>>> "ide") >>>>>> "n" defines the bus number (by default 1) >>>>>> "m" defines the unit number (by default 0) >>>>>> "mode" defines one of [disk,floppy,cdrom] >>>>>> If we ever up able to emulate other types of SCSI / IDE devices >>>>>> (tape drives, >>>>>> cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. >>>>> I agree with that. And if everyone agrees I can modify patches to do >>>>> that... >>>> Please go ahead. :-) >>> Well, it is done... is there someone that can comment them ? >>> Or if they are perfect (as usual ;-) ) perhaps it could be included in >>> CVS ? >> I had rejected a similar patch in the past, but I agree that a -disk >> command line option is needed. >> >> A few remarks: >> >> - Add a function in vl.c to add a disk so that all option handlers can >> call it instead of doing pstrcpy(); nb_disk++. > > I agree > >> - You replaced the constant "2" in many machines by MAX_IDE_BUS. It is >> dangerous because each machine has its own constraints. > > I agree, I'll use MAX_IDE_BUS only for PC. > But how can I compute MAX_DISKS if the number of IDE disks vary with > target ? What is important is that MAX_IDE_BUS is bigger than the number of IDE disks used by every machine. If the machine does not use them it is less an issue. If you use DriveInfo you no longer have this problem. > For the moment it is the sum of all available MAX_* . > Should I take an explicit value like "32" or something like ? If you use my suggestion of DriveInfo structure, this problem disappears as you will have a single constant MAX_DISKS that you can set to a fixed value. >> - Maybe the real option name could be "-drive" to insist on the fact >> that a drive can be created without a disk in it ! Any more comments ? > > I agree, and a drive can be something else like a flash or a tape (in > the future...). > >> - disk_init() should not modify its argument str. Moreover, maybe having >> an explicit "file=" argument would be clearer in the case there is no >> disk in the drive. > > I'm not sure I understand correctly this one. > For the moment "-disk ," allows to declare a drive without media (an > empty CDROM drive, for instance). > Do you mean we must use "-drive file=a.img" instead of "-disk a.img" and > "-drive file=" instead of "-disk ," Yes "-disk file=a.img" or "-disk media=cdrom". But I am open to other suggestion. I was just surprised by the syntax "-disk ,media=cdrom". >> - While modifying the machine init function, you can suppress the >> snapshot parameter. > > OK > >> - In disk_init(), you should factorize the bdrv_new() and bdrv_open() as >> it is the same for all types. > > OK. > Can I use bdrv_set_geometry_hint() and bdrv_set_translation_hint() > before the bdrv_open() ? It seems possible. >> - It could be simpler to export an array of structs containg a bdrv, >> each one tagged with if, index and bus. Then each machine could call a >> function to get the bdrv from the parameters "if", "index" and "bus". >> For example, look at the NICInfo structure and do the same with a >> structure DriveInfo... > > OK > >> If you prefer, you can resubmit a big patch with all the changes. > > Well, I like to write a lot of little patches ;-) > It is easier to review them, isn't it ? > But it is as you want. As you wish. Regards, Fabrice. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-11-07 23:32 ` Fabrice Bellard 2007-11-08 9:02 ` Laurent Vivier @ 2007-11-10 0:02 ` Laurent Vivier 1 sibling, 0 replies; 27+ messages in thread From: Laurent Vivier @ 2007-11-10 0:02 UTC (permalink / raw) To: Fabrice Bellard; +Cc: qemu-devel [-- Attachment #1.1: Type: text/plain, Size: 3795 bytes --] Hi, you can find attached a patch trying to manage your comments. This patch adds parameter "-drive" and manages all drives type supported by qemu (ide, scsi, sd, mtd, floppy, pflash). It adds a DriveInfo structure to do that. It applies on top of patch I posted 2 days ago (http://article.gmane.org/gmane.comp.emulators.qemu/21011 ) All comments are welcome, Laurent Le jeudi 08 novembre 2007 à 00:32 +0100, Fabrice Bellard a écrit : > Laurent Vivier wrote: > > Thiemo Seufer a écrit : > >> Laurent Vivier wrote: > >>> Daniel P. Berrange a écrit : > >>>> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net > >>>> wrote: > >>>>> From: Laurent Vivier <vivierl@frecb07144.(none)> > >>>>> > >>>>> This patch allows to define where is connected the CDROM device (bus, > >>>>> unit). > >>>>> It extends the "-cdrom" syntax to add these paramaters: > >>>>> > >>>>> -cdrom file[,if=type][,bus=n][,unit=m] > >>>>> > >>>>> where "type" defines the interface (by default, "ide") > >>>>> "n" defines the bus number (by default 1) > >>>>> "m" defines the unit number (by default 0) > >>>> Having a separately named arg just for CDROMs was always rather > >>>> odd/unhelpful. > >>>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc > >>>> unchanged > >>>> and use the -disk for setting up all types of disks, floppys, > >>>> cdroms, etc. It > >>>> would just require one extra field for the -disk arg: > >>>> -disk file[,if=type][,bus=n][,unit=m][,mode=mode] > >>>> where "type" defines the interface. [ide,scsi,fd] (by default, > >>>> "ide") > >>>> "n" defines the bus number (by default 1) > >>>> "m" defines the unit number (by default 0) > >>>> "mode" defines one of [disk,floppy,cdrom] > >>>> If we ever up able to emulate other types of SCSI / IDE devices > >>>> (tape drives, > >>>> cdr, dvd perhaps) then the 'mode' can easily be extended to cover them. > >>> I agree with that. And if everyone agrees I can modify patches to do > >>> that... > >> > >> Please go ahead. :-) > > > > Well, it is done... is there someone that can comment them ? > > Or if they are perfect (as usual ;-) ) perhaps it could be included in > > CVS ? > > I had rejected a similar patch in the past, but I agree that a -disk > command line option is needed. > > A few remarks: > > - Add a function in vl.c to add a disk so that all option handlers can > call it instead of doing pstrcpy(); nb_disk++. > > - You replaced the constant "2" in many machines by MAX_IDE_BUS. It is > dangerous because each machine has its own constraints. > > - Maybe the real option name could be "-drive" to insist on the fact > that a drive can be created without a disk in it ! Any more comments ? > > - disk_init() should not modify its argument str. Moreover, maybe having > an explicit "file=" argument would be clearer in the case there is no > disk in the drive. > > - While modifying the machine init function, you can suppress the > snapshot parameter. > > - In disk_init(), you should factorize the bdrv_new() and bdrv_open() as > it is the same for all types. > > - It could be simpler to export an array of structs containg a bdrv, > each one tagged with if, index and bus. Then each machine could call a > function to get the bdrv from the parameters "if", "index" and "bus". > For example, look at the NICInfo structure and do the same with a > structure DriveInfo... > > If you prefer, you can resubmit a big patch with all the changes. > > Regards, > > Fabrice. -- ------------- Laurent.Vivier@bull.net -------------- "In short: just say NO TO DRUGS and maybe you won't end up like the Hurd people." -- Linus Torvald [-- Attachment #1.2: drive-arg.patch --] [-- Type: text/x-patch, Size: 60380 bytes --] This patch introduces a new parameter allowing to define drives. The new parameter is "-drive": -drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off] where: file is the disk image type is the interface type (ide, scsi, sd, mtd, floppy, pflash) n is the bus number of the given type m is the unit number on 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 "-drive file=file,bus=1,unit=0,media=cdrom" "-hda file" is an alias for "-drive file=file,bus=0,unit=0,media=disk" "-hdb file" is an alias for "-drive file=file,bus=0,unit=1,media=disk" "-hdc file" is an alias for "-drive file=file,bus=1,unit=0,media=disk" "-hdd file" is an alias for "-drive file=file,bus=1,unit=1,media=disk" "-hda file -hdachs a,b,c" is an alias for "-drive file=file,bus=0,unit=0,cyls=a,heads=b,secs=c" You can also define a cdrom on the slace of ide0 with: "-drive file=file,if=ide,bus=0,unit=1,media=cdrom" You can define an empty cdrom: "-drive if=ide,bus=0,unit=1,media=cdrom" "-drive file=file,if=scsi,bus=0,unit=6" allows to connect the disk image file to the scsi bus 0 with the unit id 6. if there is no SCSI disk, the SCSI interface is not created. It also defines the default interface type to "scsi" for targets "realview", "SS-5", "SS-10", "versatilepb", "versatileab" to keep old behavior, where "-hda" is a SCSI disk. "-fda file" is an alias for "-drive file=file,unit=0,if=floppy" "-fdb file" is an alias for "-drive file=file,unit=1,if=floppy" "-pflash file" is an alias for "-drive file=file,if=pflash" "-mtdblock file" is an alias for "-drive file=file,if=mtd" "-sd file" becomes the alias of "-drive file=file,if=sd" "-drive file=a -drive file=b" will be interpreted like "-hda a -hdb b" -- hw/esp.c | 10 - hw/integratorcp.c | 8 hw/lsi53c895a.c | 3 hw/mips_malta.c | 15 + hw/mips_pica61.c | 21 +- hw/mips_r4k.c | 17 + hw/nand.c | 2 hw/omap_mmc.c | 2 hw/pc.c | 65 ++++-- hw/ppc405_boards.c | 29 +- hw/ppc_chrp.c | 17 + hw/ppc_oldworld.c | 3 hw/ppc_prep.c | 27 ++ hw/pxa2xx_mmci.c | 3 hw/realview.c | 17 + hw/spitz.c | 9 hw/sun4m.c | 23 +- hw/versatilepb.c | 18 + monitor.c | 11 - vl.c | 529 +++++++++++++++++++++++++++++++++++------------------ vl.h | 32 ++- 21 files changed, 595 insertions(+), 266 deletions(-) Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/vl.c 2007-11-10 00:23:32.000000000 +0100 @@ -149,12 +149,9 @@ char phys_ram_file[1024]; 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: drives_table[MAX_DRIVES] is a dummy block driver if none available to store the VM snapshots */ -BlockDriverState *bs_table[MAX_DISKS + 1], *fd_table[MAX_FD]; -BlockDriverState *pflash_table[MAX_PFLASH]; -BlockDriverState *sd_bdrv; -BlockDriverState *mtd_bdrv; +DriveInfo drives_table[MAX_DRIVES+1]; /* point to the block driver where the snapshots are managed */ BlockDriverState *bs_snapshots; int vga_ram_size; @@ -224,6 +221,10 @@ int alt_grab = 0; unsigned int nb_prom_envs = 0; const char *prom_envs[MAX_PROM_ENVS]; #endif +int nb_drives_opt; +char drives_opt[MAX_DRIVES][1024]; +int nb_drives; +DriveInfo drives[MAX_DRIVES]; #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) @@ -1740,12 +1741,9 @@ static int mux_proc_byte(CharDriverState case 's': { int i; - for (i = 0; i < MAX_DISKS; i++) { - if (bs_table[i]) - bdrv_commit(bs_table[i]); + for (i = 0; i < nb_drives; i++) { + bdrv_commit(drives_table[i].bdrv); } - if (mtd_bdrv) - bdrv_commit(mtd_bdrv); } break; case 'b': @@ -4698,6 +4696,276 @@ void do_info_network(void) } } +#define HD_ALIAS "file=%s,bus=%d,unit=%d,media=disk" +#ifdef TARGET_PPC +#define CDROM_ALIAS "bus=0,unit=1,media=cdrom" +#else +#define CDROM_ALIAS "bus=1,unit=0,media=cdrom" +#endif +#define FD_ALIAS "unit=%d,if=floppy" +#define PFLASH_ALIAS "file=%s,if=pflash" +#define MTD_ALIAS "file=%s,if=mtd" +#define SD_ALIAS "file=%s,if=sd" + +static int drive_add(const char *fmt, ...) +{ + va_list ap; + + if (nb_drives_opt >= MAX_DRIVES) { + fprintf(stderr, "qemu: too many drives\n"); + exit(1); + } + + va_start(ap, fmt); + vsnprintf(drives_opt[nb_drives_opt], sizeof(drives_opt[0]), fmt, ap); + va_end(ap); + + return nb_drives_opt++; +} + +int drive_get_index(BlockInterfaceType interface, int bus, int unit) +{ + int index; + + /* seek interface, bus and unit */ + + for (index = 0; index < nb_drives; index++) + if (drives_table[index].interface == interface && + drives_table[index].bus == bus && + drives_table[index].unit == unit) + return index; + + return -1; +} + +int drive_get_max_bus(BlockInterfaceType interface) +{ + int max_bus; + int index; + + max_bus = -1; + for (index = 0; index < nb_drives; index++) { + if(drives_table[index].interface == interface && + drives_table[index].bus > max_bus) + max_bus = drives_table[index].bus; + } + return max_bus; +} + +static int drive_init(const char *str, int snapshot, QEMUMachine *machine) +{ + char buf[16]; + char file[1024]; + BlockInterfaceType interface; + enum { MEDIA_DISK, MEDIA_CDROM } media; + int bus_id, unit_id; + int cyls, heads, secs, translation; + BlockDriverState *bdrv; + int max_devs; + + file[0] = 0; + cyls = heads = secs = 0; + bus_id = 0; + unit_id = -1; + translation = BIOS_ATA_TRANSLATION_AUTO; + + if (!strcmp(machine->name, "realview") || + !strcmp(machine->name, "SS-5") || + !strcmp(machine->name, "SS-10") || + !strcmp(machine->name, "versatilepb") || + !strcmp(machine->name, "versatileab")) { + interface = IF_SCSI; + max_devs = MAX_SCSI_DEVS; + } else { + interface = IF_IDE; + max_devs = MAX_IDE_DEVS; + } + media = MEDIA_DISK; + + /* extract parameters */ + + if (get_param_value(buf, sizeof(buf), "bus", str)) { + bus_id = 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", str)) { + unit_id = strtol(buf, NULL, 0); + if (unit_id < 0) { + fprintf(stderr, "qemu: invalid unit id\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "cyls", str)) { + cyls = 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", str)) { + heads = 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", str)) { + secs = 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", str)) { + if (!strcmp(buf, "ide")) { + interface = IF_IDE; + max_devs = MAX_IDE_DEVS; + } else if (!strcmp(buf, "scsi")) { + interface = IF_SCSI; + max_devs = MAX_SCSI_DEVS; + } else if (!strcmp(buf, "floppy")) { + interface = IF_FLOPPY; + max_devs = 0; + } else if (!strcmp(buf, "pflash")) { + interface = IF_PFLASH; + max_devs = 0; + } else if (!strcmp(buf, "mtd")) { + interface = IF_MTD; + max_devs = 0; + } else if (!strcmp(buf, "sd")) { + interface = IF_SD; + max_devs = 0; + } else { + fprintf(stderr, "unsupported bus type '%s'\n", buf); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "trans", str)) { + if (!strcmp(buf, "none")) + translation = BIOS_ATA_TRANSLATION_NONE; + else if (!strcmp(buf, "lba")) + translation = BIOS_ATA_TRANSLATION_LBA; + else if (!strcmp(buf, "auto")) + translation = BIOS_ATA_TRANSLATION_AUTO; + else { + fprintf(stderr, "qemu: invalid translation type\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "media", str)) { + if (!(strcmp(buf, "disk"))) { + media = MEDIA_DISK; + } else if (!strcmp(buf, "cdrom")) { + if (cyls || secs || heads) { + fprintf(stderr, "qemu: invalid physical CHS format\n"); + return -1; + } + media = MEDIA_CDROM; + } else { + fprintf(stderr, "qemu: invalid media\n"); + return -1; + } + } + + if (get_param_value(buf, sizeof(buf), "snapshot", str)) { + if (!(strcmp(buf, "on"))) + snapshot = 1; + else if (!(strcmp(buf, "off"))) + snapshot = 0; + else { + fprintf(stderr, "qemu: invalid snapshot option\n"); + return -1; + } + } + + get_param_value(file, sizeof(file), "file", str); + + /* if user doesn't specify a unit_id, + * try to find the first free + */ + + if (unit_id == -1) { + unit_id = 0; + while (drive_get_index(interface, bus_id, unit_id) != -1) { + unit_id++; + if (max_devs && unit_id >= max_devs) { + unit_id -= max_devs; + bus_id++; + } + } + } + + /* check unit id */ + + if (max_devs && unit_id >= max_devs) { + fprintf(stderr, "qemu: unit %d too big on bus %d (max is %d)\n", + unit_id, bus_id, max_devs - 1); + exit(1); + } + + /* + * ignore multiple definitions + */ + + if (drive_get_index(interface, bus_id, unit_id) != -1) + return 0; + + /* init */ + + snprintf(buf, sizeof(buf), "drive%d", nb_drives); + bdrv = bdrv_new(buf); + drives_table[nb_drives].bdrv = bdrv; + drives_table[nb_drives].interface = interface; + drives_table[nb_drives].bus = bus_id; + drives_table[nb_drives].unit = unit_id; + nb_drives++; + + switch(interface) { + case IF_IDE: + case IF_SCSI: + switch(media) { + case MEDIA_DISK: + if (cyls != 0) { + bdrv_set_geometry_hint(bdrv, cyls, heads, secs); + bdrv_set_translation_hint(bdrv, translation); + } + break; + case MEDIA_CDROM: + bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM); + break; + } + break; + case IF_SD: + /* FIXME: This isn't really a floppy, but it's a reasonable + approximation. */ + case IF_FLOPPY: + bdrv_set_type_hint(bdrv, BDRV_TYPE_FLOPPY); + break; + case IF_PFLASH: + case IF_MTD: + break; + } + if (!file[0]) + return 0; + if (bdrv_open(bdrv, file, snapshot ? BDRV_O_SNAPSHOT : 0) < 0 || + qemu_key_check(bdrv, file)) { + fprintf(stderr, "qemu: could not open disk image %s\n", + file); + return -1; + } + return 0; +} + /***********************************************************/ /* USB devices */ @@ -5481,8 +5749,8 @@ static BlockDriverState *get_bs_snapshot if (bs_snapshots) return bs_snapshots; - for(i = 0; i <= MAX_DISKS; i++) { - bs = bs_table[i]; + for(i = 0; i <= nb_drives; i++) { + bs = drives_table[i].bdrv; if (bdrv_can_snapshot(bs)) goto ok; } @@ -5590,8 +5858,8 @@ void do_savevm(const char *name) /* create the snapshots */ - for(i = 0; i < MAX_DISKS; i++) { - bs1 = bs_table[i]; + for(i = 0; i < nb_drives; i++) { + bs1 = drives_table[i].bdrv; if (bdrv_has_snapshot(bs1)) { if (must_delete) { ret = bdrv_snapshot_delete(bs1, old_sn->id_str); @@ -5633,8 +5901,8 @@ void do_loadvm(const char *name) saved_vm_running = vm_running; vm_stop(0); - for(i = 0; i <= MAX_DISKS; i++) { - bs1 = bs_table[i]; + for(i = 0; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv; if (bdrv_has_snapshot(bs1)) { ret = bdrv_snapshot_goto(bs1, name); if (ret < 0) { @@ -5694,8 +5962,8 @@ void do_delvm(const char *name) return; } - for(i = 0; i <= MAX_DISKS; i++) { - bs1 = bs_table[i]; + for(i = 0; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv; if (bdrv_has_snapshot(bs1)) { ret = bdrv_snapshot_delete(bs1, name); if (ret < 0) { @@ -5723,8 +5991,8 @@ void do_info_snapshots(void) return; } term_printf("Snapshot devices:"); - for(i = 0; i <= MAX_DISKS; i++) { - bs1 = bs_table[i]; + for(i = 0; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv; if (bdrv_has_snapshot(bs1)) { if (bs == bs1) term_printf(" %s", bdrv_get_device_name(bs1)); @@ -6428,15 +6696,14 @@ static void ram_save(QEMUFile *f, void * /* find if the memory block is available on a virtual block device */ sector_num = -1; - for(j = 0; j < MAX_DISKS; j++) { - if (bs_table[j]) { - sector_num = bdrv_hash_find(bs_table[j], - phys_ram_base + i, BDRV_HASH_BLOCK_SIZE); - if (sector_num >= 0) - break; - } + for(j = 0; j < nb_drives; j++) { + sector_num = bdrv_hash_find(drives_table[j].bdrv, + phys_ram_base + i, + BDRV_HASH_BLOCK_SIZE); + if (sector_num >= 0) + break; } - if (j == MAX_DISKS) + if (j == nb_drives) goto normal_compress; buf[0] = 1; buf[1] = j; @@ -6487,11 +6754,12 @@ static int ram_load(QEMUFile *f, void *o ram_decompress_buf(s, buf + 1, 9); bs_index = buf[1]; sector_num = be64_to_cpupu((const uint64_t *)(buf + 2)); - if (bs_index >= MAX_DISKS || bs_table[bs_index] == NULL) { + if (bs_index >= nb_drives) { fprintf(stderr, "Invalid block device index %d\n", bs_index); goto error; } - if (bdrv_read(bs_table[bs_index], sector_num, phys_ram_base + i, + if (bdrv_read(drives_table[bs_index].bdrv, sector_num, + phys_ram_base + i, BDRV_HASH_BLOCK_SIZE / 512) < 0) { fprintf(stderr, "Error while reading sector %d:%" PRId64 "\n", bs_index, sector_num); @@ -6988,6 +7256,8 @@ static void help(int exitcode) "-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 master)\n" + "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off]\n" + " use 'file' as a drive 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" @@ -7133,6 +7403,7 @@ enum { QEMU_OPTION_hdb, QEMU_OPTION_hdc, QEMU_OPTION_hdd, + QEMU_OPTION_drive, QEMU_OPTION_cdrom, QEMU_OPTION_mtdblock, QEMU_OPTION_sd, @@ -7222,6 +7493,7 @@ const QEMUOption qemu_options[] = { { "hdb", HAS_ARG, QEMU_OPTION_hdb }, { "hdc", HAS_ARG, QEMU_OPTION_hdc }, { "hdd", HAS_ARG, QEMU_OPTION_hdd }, + { "drive", HAS_ARG, QEMU_OPTION_drive }, { "cdrom", HAS_ARG, QEMU_OPTION_cdrom }, { "mtdblock", HAS_ARG, QEMU_OPTION_mtdblock }, { "sd", HAS_ARG, QEMU_OPTION_sd }, @@ -7334,16 +7606,9 @@ int qemu_key_check(BlockDriverState *bs, static BlockDriverState *get_bdrv(int index) { - BlockDriverState *bs; - - if (index < 4) { - bs = bs_table[index]; - } else if (index < 6) { - bs = fd_table[index - 4]; - } else { - bs = NULL; - } - return bs; + if (index > nb_drives) + return NULL; + return drives_table[index].bdrv; } static void read_passwords(void) @@ -7538,18 +7803,15 @@ int main(int argc, char **argv) int use_gdbstub; const char *gdbstub_port; #endif - int i, cdrom_index, pflash_index; + int i; int snapshot, linux_boot; const char *initrd_filename; - const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD]; - const char *pflash_filename[MAX_PFLASH]; - const char *sd_filename; - const char *mtd_filename; const char *kernel_filename, *kernel_cmdline; DisplayState *ds = &display_state; int cyls, heads, secs, translation; char net_clients[MAX_NET_CLIENTS][256]; int nb_net_clients; + int hda_index; int optind; const char *r, *optarg; CharDriverState *monitor_hd; @@ -7602,15 +7864,6 @@ int main(int argc, char **argv) machine = first_machine; cpu_model = NULL; initrd_filename = NULL; - for(i = 0; i < MAX_FD; i++) - fd_filename[i] = NULL; - for(i = 0; i < MAX_DISKS; i++) - hd_filename[i] = NULL; - for(i = 0; i < MAX_PFLASH; i++) - pflash_filename[i] = NULL; - pflash_index = 0; - sd_filename = NULL; - mtd_filename = NULL; ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; vga_ram_size = VGA_RAM_SIZE; #ifdef CONFIG_GDBSTUB @@ -7621,11 +7874,6 @@ int main(int argc, char **argv) nographic = 0; kernel_filename = NULL; kernel_cmdline = ""; -#ifdef TARGET_PPC - cdrom_index = 1; -#else - cdrom_index = 2; -#endif cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; pstrcpy(monitor_device, sizeof(monitor_device), "vc"); @@ -7643,6 +7891,9 @@ int main(int argc, char **argv) usb_devices_index = 0; nb_net_clients = 0; + nb_drives = 0; + nb_drives_opt = 0; + hda_index = -1; nb_nics = 0; /* default mac address of the first network interface */ @@ -7653,7 +7904,7 @@ int main(int argc, char **argv) break; r = argv[optind]; if (r[0] != '-') { - hd_filename[0] = argv[optind++]; + hda_index = drive_add(HD_ALIAS, argv[optind++], 0, 0); } else { const QEMUOption *popt; @@ -7713,29 +7964,38 @@ int main(int argc, char **argv) initrd_filename = optarg; break; case QEMU_OPTION_hda: + if (cyls == 0) + hda_index = drive_add(HD_ALIAS, optarg, 0, 0); + else + hda_index = drive_add(HD_ALIAS + ",cyls=%d,heads=%d,secs=%d%s", + optarg, 0, 0, cyls, heads, secs, + translation == BIOS_ATA_TRANSLATION_LBA ? + ",trans=lba" : + translation == BIOS_ATA_TRANSLATION_NONE ? + ",trans=none" : ""); + break; case QEMU_OPTION_hdb: case QEMU_OPTION_hdc: case QEMU_OPTION_hdd: { int hd_index; hd_index = popt->index - QEMU_OPTION_hda; - hd_filename[hd_index] = optarg; - if (hd_index == cdrom_index) - cdrom_index = -1; + drive_add(HD_ALIAS, optarg, hd_index / MAX_IDE_DEVS, + hd_index % MAX_IDE_DEVS); } break; + case QEMU_OPTION_drive: + drive_add("%s", optarg); + break; case QEMU_OPTION_mtdblock: - mtd_filename = optarg; + drive_add(MTD_ALIAS, optarg); break; case QEMU_OPTION_sd: - sd_filename = optarg; + drive_add(SD_ALIAS, optarg); break; case QEMU_OPTION_pflash: - if (pflash_index >= MAX_PFLASH) { - fprintf(stderr, "qemu: too many parallel flash images\n"); - exit(1); - } - pflash_filename[pflash_index++] = optarg; + drive_add(PFLASH_ALIAS, optarg); break; case QEMU_OPTION_snapshot: snapshot = 1; @@ -7774,6 +8034,17 @@ int main(int argc, char **argv) fprintf(stderr, "qemu: invalid physical CHS format\n"); exit(1); } + if (hda_index != -1) + snprintf(drives_opt[hda_index] + + strlen(drives_opt[hda_index]), + sizeof(drives_opt[0]) - + strlen(drives_opt[hda_index]), + ",cyls=%d,heads=%d,secs=%d%s", + cyls, heads, secs, + translation == BIOS_ATA_TRANSLATION_LBA ? + ",trans=lba" : + translation == BIOS_ATA_TRANSLATION_NONE ? + ",trans=none" : ""); } break; case QEMU_OPTION_nographic: @@ -7792,9 +8063,7 @@ int main(int argc, char **argv) kernel_cmdline = optarg; break; case QEMU_OPTION_cdrom: - if (cdrom_index >= 0) { - hd_filename[cdrom_index] = optarg; - } + drive_add("file=%s," CDROM_ALIAS, optarg); break; case QEMU_OPTION_boot: if (strlen(optarg) > MAX_BOOT_DEVICES) { @@ -7814,10 +8083,9 @@ int main(int argc, char **argv) } break; case QEMU_OPTION_fda: - fd_filename[0] = optarg; - break; case QEMU_OPTION_fdb: - fd_filename[1] = optarg; + drive_add("file=%s," FD_ALIAS, optarg, + popt->index - QEMU_OPTION_fda); break; #ifdef TARGET_I386 case QEMU_OPTION_no_fd_bootchk: @@ -8197,20 +8465,11 @@ int main(int argc, char **argv) if (!linux_boot && (!strchr(boot_device, 'n')) && - hd_filename[0] == '\0' && - (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') && - fd_filename[0] == '\0') + nb_drives_opt == 0) help(1); - /* boot to floppy or the default cd if no hard disk defined yet */ if (!boot_device[0]) { - if (hd_filename[0] != '\0') - boot_device[0] = 'c'; - else if (fd_filename[0] != '\0') - boot_device[0] = 'a'; - else - boot_device[0] = 'd'; - boot_device[1] = 0; + pstrcpy(boot_device, sizeof(boot_device), BOOTCHARS); } setvbuf(stdout, NULL, _IOLBF, 0); @@ -8279,97 +8538,23 @@ int main(int argc, char **argv) exit(1); } - /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); - if (cdrom_index >= 0) { - bs_table[cdrom_index] = bdrv_new("cdrom"); - bdrv_set_type_hint(bs_table[cdrom_index], BDRV_TYPE_CDROM); - } - /* open the virtual block devices */ - for(i = 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] = bdrv_new(buf); - } - if (bdrv_open(bs_table[i], hd_filename[i], snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { - fprintf(stderr, "qemu: could not open hard disk image '%s'\n", - hd_filename[i]); - exit(1); - } - if (i == 0 && cyls != 0) { - bdrv_set_geometry_hint(bs_table[i], cyls, heads, secs); - bdrv_set_translation_hint(bs_table[i], translation); - } - } - } + /* we always create the cdrom drive, even if no disk is there */ - /* we always create at least one floppy disk */ - fd_table[0] = bdrv_new("fda"); - bdrv_set_type_hint(fd_table[0], BDRV_TYPE_FLOPPY); - - for(i = 0; i < MAX_FD; i++) { - if (fd_filename[i]) { - if (!fd_table[i]) { - char buf[64]; - snprintf(buf, sizeof(buf), "fd%c", i + 'a'); - fd_table[i] = bdrv_new(buf); - bdrv_set_type_hint(fd_table[i], BDRV_TYPE_FLOPPY); - } - if (fd_filename[i][0] != '\0') { - if (bdrv_open(fd_table[i], fd_filename[i], - snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { - fprintf(stderr, "qemu: could not open floppy disk image '%s'\n", - fd_filename[i]); - exit(1); - } - } - } - } + if (nb_drives_opt < MAX_DRIVES) + drive_add(CDROM_ALIAS); - /* Open the virtual parallel flash block devices */ - for(i = 0; i < MAX_PFLASH; i++) { - if (pflash_filename[i]) { - if (!pflash_table[i]) { - char buf[64]; - snprintf(buf, sizeof(buf), "fl%c", i + 'a'); - pflash_table[i] = bdrv_new(buf); - } - if (bdrv_open(pflash_table[i], pflash_filename[i], - snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { - fprintf(stderr, "qemu: could not open flash image '%s'\n", - pflash_filename[i]); - exit(1); - } - } - } + /* we always create at least on floppy */ - sd_bdrv = 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); - } + if (nb_drives_opt < MAX_DRIVES) + drive_add(FD_ALIAS, 0); - if (mtd_filename) { - mtd_bdrv = bdrv_new ("mtd"); - if (bdrv_open(mtd_bdrv, mtd_filename, - snapshot ? BDRV_O_SNAPSHOT : 0) < 0 || - qemu_key_check(mtd_bdrv, mtd_filename)) { - fprintf(stderr, "qemu: could not open Flash image %s\n", - mtd_filename); - bdrv_delete(mtd_bdrv); - mtd_bdrv = 0; - } - } + /* open the virtual block devices */ + + for(i = 0; i < nb_drives_opt; i++) + if (drive_init(drives_opt[i], snapshot, machine) == -1) + exit(1); register_savevm("timer", 0, 2, timer_save, timer_load, NULL); register_savevm("ram", 0, 2, ram_save, ram_load, NULL); Index: qemu/vl.h =================================================================== --- qemu.orig/vl.h 2007-11-09 22:04:28.000000000 +0100 +++ qemu/vl.h 2007-11-10 00:27:58.000000000 +0100 @@ -1009,13 +1009,27 @@ void do_info_vnc(void); /* x_keymap.c */ extern uint8_t _translate_keycode(const int key); -/* ide.c */ -#define MAX_DISKS 4 +typedef enum { + IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD +} BlockInterfaceType; + +typedef struct DriveInfo { + BlockDriverState *bdrv; + BlockInterfaceType interface; + int bus; + int unit; +} DriveInfo; + +#define MAX_DRIVES 32 -extern BlockDriverState *bs_table[MAX_DISKS + 1]; -extern BlockDriverState *sd_bdrv; -extern BlockDriverState *mtd_bdrv; +extern int nb_drives; +extern DriveInfo drives_table[MAX_DRIVES+1]; +extern int drive_get_index(BlockInterfaceType interface, int bus, int unit); +extern int drive_get_max_bus(BlockInterfaceType interface); + +/* ide.c */ +#define MAX_IDE_DEVS 2 void isa_ide_init(int iobase, int iobase2, qemu_irq irq, BlockDriverState *hd0, BlockDriverState *hd1); void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table, @@ -1060,7 +1074,6 @@ void DMA_register_channel (int nchan, void *opaque); /* fdc.c */ #define MAX_FD 2 -extern BlockDriverState *fd_table[MAX_FD]; typedef struct fdctrl_t fdctrl_t; @@ -1327,8 +1340,11 @@ void *slavio_misc_init(target_phys_addr_ void slavio_set_power_fail(void *opaque, int power_failing); /* esp.c */ +/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ +#define MAX_SCSI_DEVS 7 +#define ESP_MAX_DEVS MAX_SCSI_DEVS void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id); -void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr, +void *esp_init(target_phys_addr_t espaddr, void *dma_opaque, qemu_irq irq, qemu_irq *reset); /* sparc32_dma.c */ @@ -1458,6 +1474,7 @@ void scsi_cancel_io(SCSIDevice *s, uint3 uint8_t *scsi_get_buf(SCSIDevice *s, uint32_t tag); /* lsi53c895a.c */ +#define LSI_MAX_DEVS MAX_SCSI_DEVS void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id); void *lsi_scsi_init(PCIBus *bus, int devfn); @@ -1566,7 +1583,6 @@ int tc58128_init(struct SH7750State *s, /* NOR flash devices */ #define MAX_PFLASH 4 -extern BlockDriverState *pflash_table[MAX_PFLASH]; typedef struct pflash_t pflash_t; pflash_t *pflash_register (target_phys_addr_t base, ram_addr_t off, Index: qemu/monitor.c =================================================================== --- qemu.orig/monitor.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/monitor.c 2007-11-09 22:04:33.000000000 +0100 @@ -204,16 +204,11 @@ static void do_commit(const char *device int i, all_devices; all_devices = !strcmp(device, "all"); - for (i = 0; i < MAX_DISKS; i++) { - if (bs_table[i]) { + for (i = 0; i < nb_drives; i++) { if (all_devices || - !strcmp(bdrv_get_device_name(bs_table[i]), device)) - bdrv_commit(bs_table[i]); - } + !strcmp(bdrv_get_device_name(drives_table[i].bdrv), device)) + bdrv_commit(drives_table[i].bdrv); } - if (mtd_bdrv) - if (all_devices || !strcmp(bdrv_get_device_name(mtd_bdrv), device)) - bdrv_commit(mtd_bdrv); } static void do_info(const char *item) Index: qemu/hw/mips_pica61.c =================================================================== --- qemu.orig/hw/mips_pica61.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/mips_pica61.c 2007-11-09 23:42:37.000000000 +0100 @@ -38,6 +38,8 @@ #define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) +#define MAX_IDE_BUS 2 + static const int ide_iobase[2] = { 0x1f0, 0x170 }; static const int ide_iobase2[2] = { 0x3f6, 0x376 }; static const int ide_irq[2] = { 14, 15 }; @@ -68,6 +70,8 @@ void mips_pica61_init (int ram_size, int mips_def_t *def; int available_ram; qemu_irq *i8259; + int index; + BlockDriverState *fd[MAX_FD]; /* init CPUs */ if (cpu_model == NULL) { @@ -136,9 +140,14 @@ void mips_pica61_init (int ram_size, int i8042_mm_init(i8259[6], i8259[7], 0x80005060, 0); /* IDE controller */ - for(i = 0; i < 2; i++) + for(i = 0; i < MAX_IDE_BUS; i++) { + int hd0, hd1; + hd0 = drive_get_index(IF_IDE, i, 0); + hd1 = drive_get_index(IF_IDE, i, 1); isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i + 1]); + hd0 == -1 ? NULL : drives_table[hd0].bdrv, + hd1 == -1 ? NULL : drives_table[hd1].bdrv); + } /* Network controller */ /* FIXME: missing NS SONIC DP83932 */ @@ -147,7 +156,13 @@ void mips_pica61_init (int ram_size, int /* FIXME: missing NCR 53C94 */ /* ISA devices (floppy, serial, parallel) */ - fdctrl_init(i8259[1], 1, 1, 0x80003000, fd_table); + for (i = 0; i < 2; i++) { + index = drive_get_index(IF_FLOPPY, 0, i); + if (index == -1) + continue; + fd[i] = drives_table[index].bdrv; + } + fdctrl_init(i8259[1], 1, 1, 0x80003000, fd); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_mm_init(serial_base[i], 0, i8259[serial_irq[i]], serial_hds[i], 1); Index: qemu/hw/mips_r4k.c =================================================================== --- qemu.orig/hw/mips_r4k.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/mips_r4k.c 2007-11-09 22:04:33.000000000 +0100 @@ -23,6 +23,8 @@ #define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) +#define MAX_IDE_BUS 2 + static const int ide_iobase[2] = { 0x1f0, 0x170 }; static const int ide_iobase2[2] = { 0x3f6, 0x376 }; static const int ide_irq[2] = { 14, 15 }; @@ -150,6 +152,8 @@ void mips_r4k_init (int ram_size, int vg int i; mips_def_t *def; qemu_irq *i8259; + int index; + BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; /* init CPUs */ if (cpu_model == NULL) { @@ -240,9 +244,18 @@ void mips_r4k_init (int ram_size, int vg } } - for(i = 0; i < 2; i++) + for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { + index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); + if (index != -1) + hd[i] = drives_table[index].bdrv; + else + hd[i] = NULL; + } + + for(i = 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]); + hd[MAX_IDE_DEVS * i], + hd[MAX_IDE_DEVS * i + 1]); i8042_init(i8259[1], i8259[12], 0x60); ds1225y_init(0x9000, "nvram"); Index: qemu/hw/pc.c =================================================================== --- qemu.orig/hw/pc.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/pc.c 2007-11-09 23:43:31.000000000 +0100 @@ -33,6 +33,8 @@ /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */ #define ACPI_DATA_SIZE 0x10000 +#define MAX_IDE_BUS 2 + static fdctrl_t *floppy_controller; static RTCState *rtc_state; static PITState *pit; @@ -360,8 +362,10 @@ static void generate_bootsect(uint32_t g { uint8_t bootsect[512], *p; int i; + int hda; - if (bs_table[0] == NULL) { + hda = drive_get_index(IF_IDE, 0, 0); + if (hda == -1) { fprintf(stderr, "A disk image must be given for 'hda' when booting " "a Linux kernel\n"); exit(1); @@ -370,7 +374,7 @@ static void generate_bootsect(uint32_t g memset(bootsect, 0, sizeof(bootsect)); /* Copy the MSDOS partition table if possible */ - bdrv_read(bs_table[0], 0, bootsect, 1); + bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1); /* Make sure we have a partition signature */ bootsect[510] = 0x55; @@ -407,7 +411,7 @@ static void generate_bootsect(uint32_t g *p++ = segs[1]; /* CS */ *p++ = segs[1] >> 8; - bdrv_set_boot_sector(bs_table[0], bootsect, sizeof(bootsect)); + bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect)); } int load_kernel(const char *filename, uint8_t *addr, @@ -688,6 +692,9 @@ static void pc_init1(int ram_size, int v NICInfo *nd; qemu_irq *cpu_irq; qemu_irq *i8259; + int index; + BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; + BlockDriverState *fd[MAX_FD]; linux_boot = (kernel_filename != NULL); @@ -905,12 +912,20 @@ static void pc_init1(int ram_size, int v } } + for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { + index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); + if (index != -1) + hd[i] = drives_table[index].bdrv; + else + hd[i] = NULL; + } + if (pci_enabled) { - pci_piix3_ide_init(pci_bus, bs_table, piix3_devfn + 1, i8259); + pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1, i8259); } else { - for(i = 0; i < 2; i++) { + for(i = 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]); + hd[2 * i], hd[2 * i + 1]); } } @@ -920,9 +935,16 @@ static void pc_init1(int ram_size, int v audio_init(pci_enabled ? pci_bus : NULL, i8259); #endif - floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table); + for(i = 0; i < MAX_FD; i++) { + index = drive_get_index(IF_FLOPPY, 0, i); + if (index != -1) + fd[i] = drives_table[index].bdrv; + else + fd[i] = NULL; + } + floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd); - cmos_init(ram_size, boot_device, bs_table); + cmos_init(ram_size, boot_device, hd); if (pci_enabled && usb_enabled) { usb_uhci_piix3_init(pci_bus, piix3_devfn + 2); @@ -942,23 +964,24 @@ static void pc_init1(int ram_size, int v if (i440fx_state) { i440fx_init_memory_mappings(i440fx_state); } -#if 0 - /* ??? Need to figure out some way for the user to - specify SCSI devices. */ + if (pci_enabled) { + int max_bus; + int bus, unit; void *scsi; - BlockDriverState *bdrv; - scsi = lsi_scsi_init(pci_bus, -1); - bdrv = bdrv_new("scsidisk"); - bdrv_open(bdrv, "scsi_disk.img", 0); - lsi_scsi_attach(scsi, bdrv, -1); - bdrv = bdrv_new("scsicd"); - bdrv_open(bdrv, "scsi_cd.iso", 0); - bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM); - lsi_scsi_attach(scsi, bdrv, -1); + max_bus = drive_get_max_bus(IF_SCSI); + + for (bus = 0; bus <= max_bus; bus++) { + scsi = lsi_scsi_init(pci_bus, -1); + for (unit = 0; unit < LSI_MAX_DEVS; unit++) { + index = drive_get_index(IF_SCSI, bus, unit); + if (index == -1) + continue; + lsi_scsi_attach(scsi, drives_table[index].bdrv, unit); + } + } } -#endif } static void pc_init_pci(int ram_size, int vga_ram_size, Index: qemu/hw/ppc_prep.c =================================================================== --- qemu.orig/hw/ppc_prep.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/ppc_prep.c 2007-11-09 23:44:13.000000000 +0100 @@ -29,6 +29,8 @@ /* SMP is not enabled, for now */ #define MAX_CPUS 1 +#define MAX_IDE_BUS 2 + #define BIOS_FILENAME "ppc_rom.bin" #define KERNEL_LOAD_ADDR 0x01000000 #define INITRD_LOAD_ADDR 0x01800000 @@ -540,6 +542,9 @@ static void ppc_prep_init (int ram_size, PCIBus *pci_bus; qemu_irq *i8259; int ppc_boot_device = boot_device[0]; + int index; + BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; + BlockDriverState *fd[MAX_FD]; sysctrl = qemu_mallocz(sizeof(sysctrl_t)); if (sysctrl == NULL) @@ -649,16 +654,32 @@ static void ppc_prep_init (int ram_size, } } - for(i = 0; i < 2; i++) { + for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { + index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); + if (index != -1) + hd[i] = drives_table[index].bdrv; + else + hd[i] = NULL; + } + + for(i = 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]); + hd[2 * i], + hd[2 * i + 1]); } i8042_init(i8259[1], i8259[12], 0x60); DMA_init(1); // AUD_init(); // SB16_init(); - fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table); + for(i = 0; i < MAX_FD; i++) { + index = drive_get_index(IF_FLOPPY, 0, i); + if (index != -1) + fd[i] = drives_table[index].bdrv; + else + fd[i] = NULL; + } + fdctrl_init(i8259[6], 2, 0, 0x3f0, fd); /* Register speaker port */ register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL); Index: qemu/hw/esp.c =================================================================== --- qemu.orig/hw/esp.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/esp.c 2007-11-09 22:04:33.000000000 +0100 @@ -45,14 +45,11 @@ do { printf("ESP: " fmt , ##args); } whi #define ESP_REGS 16 #define ESP_SIZE (ESP_REGS * 4) #define TI_BUFSZ 32 -/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ -#define ESP_MAX_DEVS 7 typedef struct ESPState ESPState; struct ESPState { qemu_irq irq; - BlockDriverState **bd; uint8_t rregs[ESP_REGS]; uint8_t wregs[ESP_REGS]; int32_t ti_size; @@ -60,7 +57,7 @@ struct ESPState { uint8_t ti_buf[TI_BUFSZ]; int sense; int dma; - SCSIDevice *scsi_dev[MAX_DISKS]; + SCSIDevice *scsi_dev[ESP_MAX_DEVS]; SCSIDevice *current_dev; uint8_t cmdbuf[TI_BUFSZ]; int cmdlen; @@ -122,7 +119,7 @@ static int get_cmd(ESPState *s, uint8_t s->async_len = 0; } - if (target >= MAX_DISKS || !s->scsi_dev[target]) { + if (target >= ESP_MAX_DEVS || !s->scsi_dev[target]) { // No such drive s->rregs[4] = STAT_IN; s->rregs[5] = INTR_DC; @@ -574,7 +571,7 @@ void esp_scsi_attach(void *opaque, Block s->scsi_dev[id] = scsi_disk_init(bd, 0, esp_command_complete, s); } -void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr, +void *esp_init(target_phys_addr_t espaddr, void *dma_opaque, qemu_irq irq, qemu_irq *reset) { ESPState *s; @@ -584,7 +581,6 @@ void *esp_init(BlockDriverState **bd, ta if (!s) return NULL; - s->bd = bd; s->irq = irq; s->dma_opaque = dma_opaque; Index: qemu/hw/realview.c =================================================================== --- qemu.orig/hw/realview.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/realview.c 2007-11-10 00:29:49.000000000 +0100 @@ -24,6 +24,7 @@ static void realview_init(int ram_size, NICInfo *nd; int n; int done_smc = 0; + int index; env = cpu_init(); if (!cpu_model) @@ -55,7 +56,12 @@ static void realview_init(int ram_size, pl110_init(ds, 0x10020000, pic[23], 1); - pl181_init(0x10005000, sd_bdrv, pic[17], pic[18]); + index = drive_get_index(IF_SD, 0, 0); + if (index == -1) { + fprintf(stderr, "qemu: missing SecureDigital card\n"); + exit(1); + } + pl181_init(0x10005000, drives_table[index].bdrv, pic[17], pic[18]); pl031_init(0x10017000, pic[10]); @@ -64,10 +70,11 @@ static void realview_init(int ram_size, usb_ohci_init_pci(pci_bus, 3, -1); } scsi_hba = lsi_scsi_init(pci_bus, -1); - for (n = 0; n < MAX_DISKS; n++) { - if (bs_table[n]) { - lsi_scsi_attach(scsi_hba, bs_table[n], n); - } + for (n = 0; n < LSI_MAX_DEVS; n++) { + index = drive_get_index(IF_SCSI, 0, n); + if (index == -1) + continue; + lsi_scsi_attach(scsi_hba, drives_table[index].bdrv, n); } for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; Index: qemu/hw/sun4m.c =================================================================== --- qemu.orig/hw/sun4m.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/sun4m.c 2007-11-09 23:44:31.000000000 +0100 @@ -317,6 +317,8 @@ static void *sun4m_hw_init(const struct qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq, *espdma_irq, *ledma_irq; qemu_irq *esp_reset, *le_reset; + BlockDriverState *fd[MAX_FD]; + int index; /* init CPUs */ sparc_find_by_name(cpu_model, &def); @@ -390,15 +392,24 @@ static void *sun4m_hw_init(const struct slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq], serial_hds[1], serial_hds[0]); - sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd_table); + for(i = 0; i < MAX_FD; i++) { + index = drive_get_index(IF_FLOPPY, 0, i); + if (index != -1) + fd[i] = drives_table[index].bdrv; + else + fd[i] = NULL; + } + + sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd); - main_esp = esp_init(bs_table, hwdef->esp_base, espdma, *espdma_irq, + main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq, esp_reset); - for (i = 0; i < MAX_DISKS; i++) { - if (bs_table[i]) { - esp_scsi_attach(main_esp, bs_table[i], i); - } + for (i = 0; i < ESP_MAX_DEVS; i++) { + index = drive_get_index(IF_SCSI, 0, i); + if (index == -1) + continue; + esp_scsi_attach(main_esp, drives_table[index].bdrv, i); } slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->power_base, Index: qemu/hw/versatilepb.c =================================================================== --- qemu.orig/hw/versatilepb.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/versatilepb.c 2007-11-09 23:44:49.000000000 +0100 @@ -165,6 +165,7 @@ static void versatile_init(int ram_size, NICInfo *nd; int n; int done_smc = 0; + int index; env = cpu_init(); if (!cpu_model) @@ -198,10 +199,11 @@ static void versatile_init(int ram_size, usb_ohci_init_pci(pci_bus, 3, -1); } scsi_hba = lsi_scsi_init(pci_bus, -1); - for (n = 0; n < MAX_DISKS; n++) { - if (bs_table[n]) { - lsi_scsi_attach(scsi_hba, bs_table[n], n); - } + for (n = 0; n < LSI_MAX_DEVS; n++) { + index = drive_get_index(IF_SCSI, 0, n); + if (index == -1) + continue; + lsi_scsi_attach(scsi_hba, drives_table[index].bdrv, n); } pl011_init(0x101f1000, pic[12], serial_hds[0]); @@ -217,7 +219,13 @@ static void versatile_init(int ram_size, that includes hardware cursor support from the PL111. */ pl110_init(ds, 0x10120000, pic[16], 1); - pl181_init(0x10005000, sd_bdrv, sic[22], sic[1]); + index = drive_get_index(IF_SD, 0, 0); + if (index == -1) { + fprintf(stderr, "qemu: missing SecureDigital card\n"); + exit(1); + } + + pl181_init(0x10005000, drives_table[index].bdrv, sic[22], sic[1]); #if 0 /* Disabled because there's no way of specifying a block device. */ pl181_init(0x1000b000, NULL, sic, 23, 2); Index: qemu/hw/integratorcp.c =================================================================== --- qemu.orig/hw/integratorcp.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/integratorcp.c 2007-11-09 23:42:18.000000000 +0100 @@ -471,6 +471,7 @@ static void integratorcp_init(int ram_si uint32_t bios_offset; qemu_irq *pic; qemu_irq *cpu_pic; + int sd; env = cpu_init(); if (!cpu_model) @@ -496,7 +497,12 @@ static void integratorcp_init(int ram_si icp_control_init(0xcb000000); pl050_init(0x18000000, pic[3], 0); pl050_init(0x19000000, pic[4], 1); - pl181_init(0x1c000000, sd_bdrv, pic[23], pic[24]); + sd = drive_get_index(IF_SD, 0, 0); + if (sd == -1) { + fprintf(stderr, "qemu: missing SecureDigital card for integratorcp\n"); + exit(1); + } + pl181_init(0x1c000000, drives_table[sd].bdrv, pic[23], pic[24]); if (nd_table[0].vlan) { if (nd_table[0].model == NULL || strcmp(nd_table[0].model, "smc91c111") == 0) { Index: qemu/hw/lsi53c895a.c =================================================================== --- qemu.orig/hw/lsi53c895a.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/lsi53c895a.c 2007-11-09 22:04:33.000000000 +0100 @@ -149,9 +149,6 @@ do { fprintf(stderr, "lsi_scsi: error: " #define PHASE_MI 7 #define PHASE_MASK 7 -/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ -#define LSI_MAX_DEVS 7 - /* Maximum length of MSG IN data. */ #define LSI_MAX_MSGIN_LEN 8 Index: qemu/hw/nand.c =================================================================== --- qemu.orig/hw/nand.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/nand.c 2007-11-09 23:42:55.000000000 +0100 @@ -447,7 +447,7 @@ struct nand_flash_s *nand_init(int manf_ } s = (struct nand_flash_s *) qemu_mallocz(sizeof(struct nand_flash_s)); - s->bdrv = mtd_bdrv; + s->bdrv = drives_table[drive_get_index(IF_MTD, 0, 0)].bdrv; s->manf_id = manf_id; s->chip_id = chip_id; s->size = nand_flash_ids[s->chip_id].size << 20; Index: qemu/hw/omap_mmc.c =================================================================== --- qemu.orig/hw/omap_mmc.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/omap_mmc.c 2007-11-09 23:43:06.000000000 +0100 @@ -540,7 +540,7 @@ struct omap_mmc_s *omap_mmc_init(target_ cpu_register_physical_memory(s->base, 0x800, iomemtype); /* Instantiate the storage */ - s->card = sd_init(sd_bdrv); + s->card = sd_init(drives_table[drive_get_index(IF_SD, 0, 0)].bdrv); sd_set_cb(s->card, s, omap_mmc_ro_cb, omap_mmc_cover_cb); Index: qemu/hw/ppc405_boards.c =================================================================== --- qemu.orig/hw/ppc405_boards.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/ppc405_boards.c 2007-11-09 23:44:02.000000000 +0100 @@ -191,6 +191,7 @@ static void ref405ep_init (int ram_size, int linux_boot; int fl_idx, fl_sectors, len; int ppc_boot_device = boot_device[0]; + int index; /* XXX: fix this */ ram_bases[0] = 0x00000000; @@ -217,17 +218,18 @@ static void ref405ep_init (int ram_size, bios_offset = sram_offset + sram_size; fl_idx = 0; #ifdef USE_FLASH_BIOS - if (pflash_table[fl_idx] != NULL) { - bios_size = bdrv_getlength(pflash_table[fl_idx]); + index = drive_get_index(IF_PFLASH, 0, fl_idx); + if (index != -1) { + bios_size = bdrv_getlength(drives_table[index].bdrv); fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s' %d\n", fl_idx, bios_size, bios_offset, -bios_size, - bdrv_get_device_name(pflash_table[fl_idx]), fl_sectors); + bdrv_get_device_name(drives_table[index].bdrv), fl_sectors); #endif pflash_register((uint32_t)(-bios_size), bios_offset, - pflash_table[fl_idx], 65536, fl_sectors, 2, + drives_table[index].bdrv, 65536, fl_sectors, 2, 0x0001, 0x22DA, 0x0000, 0x0000); fl_idx++; } else @@ -513,6 +515,7 @@ static void taihu_405ep_init(int ram_siz int linux_boot; int fl_idx, fl_sectors; int ppc_boot_device = boot_device[0]; + int index; /* RAM is soldered to the board so the size cannot be changed */ ram_bases[0] = 0x00000000; @@ -530,8 +533,9 @@ static void taihu_405ep_init(int ram_siz #endif fl_idx = 0; #if defined(USE_FLASH_BIOS) - if (pflash_table[fl_idx] != NULL) { - bios_size = bdrv_getlength(pflash_table[fl_idx]); + index = drive_get_index(IF_PFLASH, 0, fl_idx); + if (index != -1) { + bios_size = bdrv_getlength(drives_table[index].bdrv); /* XXX: should check that size is 2MB */ // bios_size = 2 * 1024 * 1024; fl_sectors = (bios_size + 65535) >> 16; @@ -539,10 +543,10 @@ static void taihu_405ep_init(int ram_siz printf("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s' %d\n", fl_idx, bios_size, bios_offset, -bios_size, - bdrv_get_device_name(pflash_table[fl_idx]), fl_sectors); + bdrv_get_device_name(drives_table[index].bdrv), fl_sectors); #endif pflash_register((uint32_t)(-bios_size), bios_offset, - pflash_table[fl_idx], 65536, fl_sectors, 4, + drives_table[index].bdrv, 65536, fl_sectors, 4, 0x0001, 0x22DA, 0x0000, 0x0000); fl_idx++; } else @@ -565,8 +569,9 @@ static void taihu_405ep_init(int ram_siz } bios_offset += bios_size; /* Register Linux flash */ - if (pflash_table[fl_idx] != NULL) { - bios_size = bdrv_getlength(pflash_table[fl_idx]); + index = drive_get_index(IF_PFLASH, 0, fl_idx); + if (index != -1) { + bios_size = bdrv_getlength(drives_table[index].bdrv); /* XXX: should check that size is 32MB */ bios_size = 32 * 1024 * 1024; fl_sectors = (bios_size + 65535) >> 16; @@ -574,9 +579,9 @@ static void taihu_405ep_init(int ram_siz printf("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s'\n", fl_idx, bios_size, bios_offset, (target_ulong)0xfc000000, - bdrv_get_device_name(pflash_table[fl_idx])); + bdrv_get_device_name(drives_table[index].bdrv)); #endif - pflash_register(0xfc000000, bios_offset, pflash_table[fl_idx], + pflash_register(0xfc000000, bios_offset, drives_table[index].bdrv, 65536, fl_sectors, 4, 0x0001, 0x22DA, 0x0000, 0x0000); fl_idx++; Index: qemu/hw/ppc_chrp.c =================================================================== --- qemu.orig/hw/ppc_chrp.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/ppc_chrp.c 2007-11-09 22:04:33.000000000 +0100 @@ -25,6 +25,8 @@ #include "vl.h" #include "ppc_mac.h" +#define MAX_IDE_BUS 2 + /* UniN device */ static void unin_writel (void *opaque, target_phys_addr_t addr, uint32_t value) { @@ -75,6 +77,8 @@ static void ppc_core99_init (int ram_siz int pic_mem_index, dbdma_mem_index, cuda_mem_index; int ide_mem_index[2]; int ppc_boot_device = boot_device[0]; + int index; + BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; linux_boot = (kernel_filename != NULL); @@ -248,11 +252,18 @@ static void ppc_core99_init (int ram_siz nd_table[i].model = "ne2k_pci"; pci_nic_init(pci_bus, &nd_table[i], -1); } + for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { + index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); + if (index != -1) + hd[i] = drives_table[index].bdrv; + else + hd[i] = NULL; + } #if 1 - ide_mem_index[0] = pmac_ide_init(&bs_table[0], pic[0x13]); - ide_mem_index[1] = pmac_ide_init(&bs_table[2], pic[0x14]); + ide_mem_index[0] = pmac_ide_init(&hd[0], pic[0x13]); + ide_mem_index[1] = pmac_ide_init(&hd[2], pic[0x14]); #else - pci_cmd646_ide_init(pci_bus, &bs_table[0], 0); + pci_cmd646_ide_init(pci_bus, &hd[0], 0); #endif /* cuda also initialize ADB */ cuda_init(&cuda_mem_index, pic[0x19]); Index: qemu/hw/ppc_oldworld.c =================================================================== --- qemu.orig/hw/ppc_oldworld.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/ppc_oldworld.c 2007-11-09 22:04:33.000000000 +0100 @@ -262,7 +262,8 @@ static void ppc_heathrow_init (int ram_s pci_nic_init(pci_bus, &nd_table[i], -1); } - pci_cmd646_ide_init(pci_bus, &bs_table[0], 0); + pci_cmd646_ide_init(pci_bus, + drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, 0); /* cuda also initialize ADB */ cuda_init(&cuda_mem_index, pic[0x12]); Index: qemu/hw/pxa2xx_mmci.c =================================================================== --- qemu.orig/hw/pxa2xx_mmci.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/pxa2xx_mmci.c 2007-11-10 00:31:45.000000000 +0100 @@ -537,7 +537,8 @@ struct pxa2xx_mmci_s *pxa2xx_mmci_init(t cpu_register_physical_memory(base, 0x00100000, iomemtype); /* Instantiate the actual storage */ - s->card = sd_init(sd_bdrv); + + s->card = sd_init(drives_table[drive_get_index(IF_SD, 0, 0)].bdrv); register_savevm("pxa2xx_mmci", 0, 0, pxa2xx_mmci_save, pxa2xx_mmci_load, s); Index: qemu/hw/spitz.c =================================================================== --- qemu.orig/hw/spitz.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/spitz.c 2007-11-09 22:04:33.000000000 +0100 @@ -924,9 +924,14 @@ static void spitz_ssp_attach(struct pxa2 static void spitz_microdrive_attach(struct pxa2xx_state_s *cpu) { struct pcmcia_card_s *md; - BlockDriverState *bs = bs_table[0]; + int index; + BlockDriverState *bs; - if (bs && bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) { + index = drive_get_index(IF_IDE, 0, 0); + if (index == -1) + return; + bs = drives_table[index].bdrv; + if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) { md = dscm1xxxx_init(bs); pxa2xx_pcmcia_attach(cpu->pcmcia[1], md); } Index: qemu/hw/mips_malta.c =================================================================== --- qemu.orig/hw/mips_malta.c 2007-11-09 22:04:28.000000000 +0100 +++ qemu/hw/mips_malta.c 2007-11-09 22:04:33.000000000 +0100 @@ -42,6 +42,8 @@ #define ENVP_NB_ENTRIES 16 #define ENVP_ENTRY_SIZE 256 +#define MAX_IDE_BUS 2 + extern FILE *logfile; typedef struct { @@ -760,6 +762,8 @@ void mips_malta_init (int ram_size, int uint8_t *eeprom_buf; i2c_bus *smbus; int i; + int index; + BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; /* init CPUs */ if (cpu_model == NULL) { @@ -845,8 +849,17 @@ void mips_malta_init (int ram_size, int pci_bus = pci_gt64120_init(i8259); /* Southbridge */ + + for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { + index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); + if (index != -1) + hd[i] = drives_table[index].bdrv; + else + hd[i] = NULL; + } + piix4_devfn = piix4_init(pci_bus, 80); - pci_piix4_ide_init(pci_bus, bs_table, piix4_devfn + 1, i8259); + pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1, i8259); usb_uhci_piix4_init(pci_bus, piix4_devfn + 2); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100); eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */ [-- Attachment #2: Ceci est une partie de message numériquement signée --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 13:25 ` Daniel P. Berrange 2007-10-29 14:02 ` Laurent Vivier @ 2007-10-29 14:49 ` andrzej zaborowski 2007-10-29 15:23 ` Thiemo Seufer 2007-10-29 15:28 ` Daniel P. Berrange 1 sibling, 2 replies; 27+ messages in thread From: andrzej zaborowski @ 2007-10-29 14:49 UTC (permalink / raw) To: Daniel P. Berrange, qemu-devel On 29/10/2007, Daniel P. Berrange <berrange@redhat.com> wrote: > On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: > > From: Laurent Vivier <vivierl@frecb07144.(none)> > > > > This patch allows to define where is connected the CDROM device (bus, > > unit). > > It extends the "-cdrom" syntax to add these paramaters: > > > > -cdrom file[,if=type][,bus=n][,unit=m] > > > > where "type" defines the interface (by default, "ide") > > "n" defines the bus number (by default 1) > > "m" defines the unit number (by default 0) > > > Having a separately named arg just for CDROMs was always rather odd/unhelpful. > I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc unchanged > and use the -disk for setting up all types of disks, floppys, cdroms, etc. It > would just require one extra field for the -disk arg: Sounds logical and I thought this was the plan. I also wouldn't mind having -sda, -sdb... following the intuitive naming based on linux /dev, but IIRC there were some people on the list who didn't like this idea. (I know /dev/sda doesn't have to be an SCSI disk on some recent systems, but it's still the most intuitive name for most users). Regards ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 14:49 ` andrzej zaborowski @ 2007-10-29 15:23 ` Thiemo Seufer 2007-10-29 15:28 ` Daniel P. Berrange 1 sibling, 0 replies; 27+ messages in thread From: Thiemo Seufer @ 2007-10-29 15:23 UTC (permalink / raw) To: andrzej zaborowski; +Cc: qemu-devel andrzej zaborowski wrote: > On 29/10/2007, Daniel P. Berrange <berrange@redhat.com> wrote: > > On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: > > > From: Laurent Vivier <vivierl@frecb07144.(none)> > > > > > > This patch allows to define where is connected the CDROM device (bus, > > > unit). > > > It extends the "-cdrom" syntax to add these paramaters: > > > > > > -cdrom file[,if=type][,bus=n][,unit=m] > > > > > > where "type" defines the interface (by default, "ide") > > > "n" defines the bus number (by default 1) > > > "m" defines the unit number (by default 0) > > > > > > Having a separately named arg just for CDROMs was always rather odd/unhelpful. > > I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc unchanged > > and use the -disk for setting up all types of disks, floppys, cdroms, etc. It > > would just require one extra field for the -disk arg: > > Sounds logical and I thought this was the plan. I also wouldn't mind > having -sda, -sdb... following the intuitive naming based on linux > /dev, but IIRC there were some people on the list who didn't like this > idea. (I know /dev/sda doesn't have to be an SCSI disk on some recent > systems, but it's still the most intuitive name for most users). But it won't hold in future, and on non-Linux systems. A -disk parameter with backward compatibility aliases sounds good to me. Thiemo ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 14:49 ` andrzej zaborowski 2007-10-29 15:23 ` Thiemo Seufer @ 2007-10-29 15:28 ` Daniel P. Berrange 2007-10-29 17:14 ` andrzej zaborowski 1 sibling, 1 reply; 27+ messages in thread From: Daniel P. Berrange @ 2007-10-29 15:28 UTC (permalink / raw) To: andrzej zaborowski; +Cc: qemu-devel On Mon, Oct 29, 2007 at 03:49:18PM +0100, andrzej zaborowski wrote: > On 29/10/2007, Daniel P. Berrange <berrange@redhat.com> wrote: > > On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: > > > From: Laurent Vivier <vivierl@frecb07144.(none)> > > > > > > This patch allows to define where is connected the CDROM device (bus, > > > unit). > > > It extends the "-cdrom" syntax to add these paramaters: > > > > > > -cdrom file[,if=type][,bus=n][,unit=m] > > > > > > where "type" defines the interface (by default, "ide") > > > "n" defines the bus number (by default 1) > > > "m" defines the unit number (by default 0) > > > > > > Having a separately named arg just for CDROMs was always rather odd/unhelpful. > > I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc unchanged > > and use the -disk for setting up all types of disks, floppys, cdroms, etc. It > > would just require one extra field for the -disk arg: > > Sounds logical and I thought this was the plan. I also wouldn't mind > having -sda, -sdb... following the intuitive naming based on linux > /dev, but IIRC there were some people on the list who didn't like this > idea. (I know /dev/sda doesn't have to be an SCSI disk on some recent > systems, but it's still the most intuitive name for most users). Adding more -sda arguments is just asking for trouble. On recent Fedora, even IDE disks will end up as /dev/sdNNN named devices. So what happens when you have -hda & -sda at same time.... pain & suffering is what happens :-) Avoiding device names as args by just using -disk is nicer Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=| ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 15:28 ` Daniel P. Berrange @ 2007-10-29 17:14 ` andrzej zaborowski 2007-10-29 21:58 ` Anthony Liguori 0 siblings, 1 reply; 27+ messages in thread From: andrzej zaborowski @ 2007-10-29 17:14 UTC (permalink / raw) To: Daniel P. Berrange; +Cc: qemu-devel On 29/10/2007, Daniel P. Berrange <berrange@redhat.com> wrote: > On Mon, Oct 29, 2007 at 03:49:18PM +0100, andrzej zaborowski wrote: > > On 29/10/2007, Daniel P. Berrange <berrange@redhat.com> wrote: > > > On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: > > > > From: Laurent Vivier <vivierl@frecb07144.(none)> > > > > > > > > This patch allows to define where is connected the CDROM device (bus, > > > > unit). > > > > It extends the "-cdrom" syntax to add these paramaters: > > > > > > > > -cdrom file[,if=type][,bus=n][,unit=m] > > > > > > > > where "type" defines the interface (by default, "ide") > > > > "n" defines the bus number (by default 1) > > > > "m" defines the unit number (by default 0) > > > > > > > > > Having a separately named arg just for CDROMs was always rather odd/unhelpful. > > > I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc unchanged > > > and use the -disk for setting up all types of disks, floppys, cdroms, etc. It > > > would just require one extra field for the -disk arg: > > > > Sounds logical and I thought this was the plan. I also wouldn't mind > > having -sda, -sdb... following the intuitive naming based on linux > > /dev, but IIRC there were some people on the list who didn't like this > > idea. (I know /dev/sda doesn't have to be an SCSI disk on some recent > > systems, but it's still the most intuitive name for most users). > > Adding more -sda arguments is just asking for trouble. On recent Fedora, > even IDE disks will end up as /dev/sdNNN named devices. So what happens > when you have -hda & -sda at same time.... pain & suffering is what > happens :-) Avoiding device names as args by just using -disk is nicer Apart from the -sda discussion (which I still think is the most intuitive choice, as an alias), I don't think having IDE and SCSI disks in one machine should be any concern? Regards ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom 2007-10-29 17:14 ` andrzej zaborowski @ 2007-10-29 21:58 ` Anthony Liguori 0 siblings, 0 replies; 27+ messages in thread From: Anthony Liguori @ 2007-10-29 21:58 UTC (permalink / raw) To: qemu-devel andrzej zaborowski wrote: > On 29/10/2007, Daniel P. Berrange <berrange@redhat.com> wrote: > >> On Mon, Oct 29, 2007 at 03:49:18PM +0100, andrzej zaborowski wrote: >> >>> On 29/10/2007, Daniel P. Berrange <berrange@redhat.com> wrote: >>> >>>> On Sun, Oct 28, 2007 at 11:43:33PM +0100, Laurent.Vivier@bull.net wrote: >>>> >>>>> From: Laurent Vivier <vivierl@frecb07144.(none)> >>>>> >>>>> This patch allows to define where is connected the CDROM device (bus, >>>>> unit). >>>>> It extends the "-cdrom" syntax to add these paramaters: >>>>> >>>>> -cdrom file[,if=type][,bus=n][,unit=m] >>>>> >>>>> where "type" defines the interface (by default, "ide") >>>>> "n" defines the bus number (by default 1) >>>>> "m" defines the unit number (by default 0) >>>>> >>>> Having a separately named arg just for CDROMs was always rather odd/unhelpful. >>>> I'd suggest that we leave all the -hda,hdb,hdc,-cdrom,-fda,-fdb etc unchanged >>>> and use the -disk for setting up all types of disks, floppys, cdroms, etc. It >>>> would just require one extra field for the -disk arg: >>>> >>> Sounds logical and I thought this was the plan. I also wouldn't mind >>> having -sda, -sdb... following the intuitive naming based on linux >>> /dev, but IIRC there were some people on the list who didn't like this >>> idea. (I know /dev/sda doesn't have to be an SCSI disk on some recent >>> systems, but it's still the most intuitive name for most users). >>> >> Adding more -sda arguments is just asking for trouble. On recent Fedora, >> even IDE disks will end up as /dev/sdNNN named devices. So what happens >> when you have -hda & -sda at same time.... pain & suffering is what >> happens :-) Avoiding device names as args by just using -disk is nicer >> > > Apart from the -sda discussion (which I still think is the most > intuitive choice, as an alias), I don't think having IDE and SCSI > disks in one machine should be any concern? > I agree that -sda is more intuitive at the moment but I think what Dan is pointing out is that in the future, -hda may end up not being used in the distros at all so while -hda/-sda makes sense today, in a couple years it may become a source of confusion. While -disk seems a bit painful, it probably is the most intuitive thing to use in the long run. Regards, Anthony Liguori > Regards > > > > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target 2007-10-28 22:43 [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Laurent.Vivier @ 2007-10-31 9:50 ` Dan Kenigsberg 2007-10-31 10:17 ` Laurent Vivier 1 sibling, 1 reply; 27+ messages in thread From: Dan Kenigsberg @ 2007-10-31 9:50 UTC (permalink / raw) To: qemu-devel Hi, I have some newby's questions: is a speedup expected, comparing to ide (I didn't notice any)? Can the PC boot from a SCSI-mounted device (I did not succeede)? ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target 2007-10-31 9:50 ` [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target Dan Kenigsberg @ 2007-10-31 10:17 ` Laurent Vivier 2007-10-31 12:56 ` Dan Kenigsberg 0 siblings, 1 reply; 27+ messages in thread From: Laurent Vivier @ 2007-10-31 10:17 UTC (permalink / raw) To: qemu-devel Dan Kenigsberg a écrit : > Hi, > > I have some newby's questions: is a speedup expected, comparing to ide We should have a speedup. But an improvement can also be to interface a _real_ SCSI disk and send directly to it the SCSI commands generated by the _virtual_ SCSI interface (as it is done in BasiliskII emulator) > (I didn't notice any)? Can the PC boot from a SCSI-mounted device (I did > not succeede)? To be able to boot from a SCSI disk we need a BIOS extension managing the SCSI card and allowing the BIOS to load the boot sector from the SCSI disk. Laurent -- ---------------- Laurent.Vivier@bull.net ----------------- "Given enough eyeballs, all bugs are shallow" E. S. Raymond ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target 2007-10-31 10:17 ` Laurent Vivier @ 2007-10-31 12:56 ` Dan Kenigsberg 2007-10-31 13:48 ` Daniel P. Berrange 0 siblings, 1 reply; 27+ messages in thread From: Dan Kenigsberg @ 2007-10-31 12:56 UTC (permalink / raw) To: qemu-devel On Wed, Oct 31, 2007 at 11:17:23AM +0100, Laurent Vivier wrote: > Dan Kenigsberg a écrit : > >Hi, > > > >I have some newby's questions: is a speedup expected, comparing to ide > > We should have a speedup. Would you suggest where it could show? I was trying simple dd and bonnie++, and saw big variace between consequtive runs, but little change between mounting an image with if=ide and if=scsi. Was I doing something wrong? > But an improvement can also be to interface a _real_ SCSI disk and send > directly to it the SCSI commands generated by the _virtual_ SCSI interface > (as it is done in BasiliskII emulator) And regardless of any improvement it's important enough to have this feature avaiable. Regards, Dan. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target 2007-10-31 12:56 ` Dan Kenigsberg @ 2007-10-31 13:48 ` Daniel P. Berrange 0 siblings, 0 replies; 27+ messages in thread From: Daniel P. Berrange @ 2007-10-31 13:48 UTC (permalink / raw) To: qemu-devel On Wed, Oct 31, 2007 at 02:56:53PM +0200, Dan Kenigsberg wrote: > On Wed, Oct 31, 2007 at 11:17:23AM +0100, Laurent Vivier wrote: > > Dan Kenigsberg a écrit : > > >Hi, > > > > > >I have some newby's questions: is a speedup expected, comparing to ide > > > > We should have a speedup. > > Would you suggest where it could show? I was trying simple dd and > bonnie++, and saw big variace between consequtive runs, but little > change between mounting an image with if=ide and if=scsi. Was I doing > something wrong? Using dd is pretty useless as a benchmark. bonnie++ can work sometimes if you tune the size of its I/O ops wrt to the amount of RAM in your host and guest. The big variance is likely caused by doing small enough I/O that the cache in either host or guest can buffer your data at times. IOZone is a benchmark I find gives better results, though it does take a hell of a long time to run. Tune IOZone params to do increasingly large I/O chunks, so that it will exceed RAM in both host & guest & let it repeat many times & you should get to some stable benchmark results. There were some results at the last Xen summit comparing the IDE & SCSI drivers in QEMU(KVM) against Xen paravirt - the SCSI results were very impressive & significantly ahead of IDE. http://xen.org/files/xensummit_4/xen_summit_2007_spring_hvm_charts_Harper.pdf Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=| ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2007-11-10 0:03 UTC | newest] Thread overview: 27+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-10-28 22:43 [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 2/3] Add arg -disk to define new disk with more features Laurent.Vivier 2007-10-28 22:43 ` [Qemu-devel] [PATCH 3/3] Add scsi support to pc target Laurent.Vivier 2007-10-29 12:03 ` [Qemu-devel] [PATCH 1/3] Add args to -cdrom to define where is connected the cdrom Johannes Schindelin 2007-10-29 12:36 ` Laurent Vivier 2007-10-29 13:25 ` Daniel P. Berrange 2007-10-29 14:02 ` Laurent Vivier 2007-10-29 14:07 ` risc 2007-10-29 14:54 ` Markus Hitter 2007-10-29 15:46 ` Laurent Vivier 2007-10-29 17:23 ` Blue Swirl 2007-10-29 14:34 ` Thiemo Seufer 2007-11-02 13:24 ` Laurent Vivier 2007-11-07 23:32 ` Fabrice Bellard 2007-11-08 9:02 ` Laurent Vivier 2007-11-08 9:33 ` Fabrice Bellard 2007-11-10 0:02 ` Laurent Vivier 2007-10-29 14:49 ` andrzej zaborowski 2007-10-29 15:23 ` Thiemo Seufer 2007-10-29 15:28 ` Daniel P. Berrange 2007-10-29 17:14 ` andrzej zaborowski 2007-10-29 21:58 ` Anthony Liguori 2007-10-31 9:50 ` [Qemu-devel] [PATCH 0/3] Add SCSI support for PC target Dan Kenigsberg 2007-10-31 10:17 ` Laurent Vivier 2007-10-31 12:56 ` Dan Kenigsberg 2007-10-31 13:48 ` Daniel P. Berrange
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).