aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-02-21 13:58:50 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-02-21 13:58:50 +0000
commita1cf5fac2b929ffa2abd1285401f2535ff8c6fea (patch)
tree1cadd786c3de02c3d817bb934b24b3b45f7369e1
parenta0775e28cd6cae7eae248f74db7bc4a03da20c6b (diff)
parentf778a82f0c179634892ea716970d4d35264dc841 (diff)
Merge remote-tracking branch 'remotes/armbru/tags/pull-block-2017-02-21' into staging
Changes to -drive without if= and with if=scsi # gpg: Signature made Tue 21 Feb 2017 12:22:35 GMT # gpg: using RSA key 0x3870B400EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-block-2017-02-21: hw/i386: Deprecate -drive if=scsi with PC machine types hw: Deprecate -drive if=scsi with non-onboard HBAs hw/scsi: Concentrate -drive if=scsi auto-create in one place hw: Drop superfluous special checks for orphaned -drive blockdev: Make orphaned -drive fatal blockdev: Improve message for orphaned -drive hw/arm/highbank: Default -drive to if=ide instead of if=scsi hw: Default -drive to if=none instead of scsi when scsi cannot work hw: Default -drive to if=none instead of ide when ide cannot work hw/arm/cubieboard hw/arm/xlnx-ep108: Fix units_per_default_bus hw: Default -drive to if=ide explicitly where it works Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--blockdev.c23
-rw-r--r--hw/alpha/dp264.c1
-rw-r--r--hw/arm/cubieboard.c4
-rw-r--r--hw/arm/highbank.c8
-rw-r--r--hw/arm/realview.c3
-rw-r--r--hw/arm/spitz.c3
-rw-r--r--hw/arm/tosa.c1
-rw-r--r--hw/arm/versatilepb.c2
-rw-r--r--hw/arm/vexpress.c1
-rw-r--r--hw/arm/xilinx_zynq.c1
-rw-r--r--hw/arm/xlnx-ep108.c6
-rw-r--r--hw/i386/pc.c7
-rw-r--r--hw/ide/core.c17
-rw-r--r--hw/mips/mips_fulong2e.c1
-rw-r--r--hw/mips/mips_jazz.c4
-rw-r--r--hw/mips/mips_malta.c1
-rw-r--r--hw/mips/mips_r4k.c1
-rw-r--r--hw/ppc/mac_newworld.c1
-rw-r--r--hw/ppc/mac_oldworld.c1
-rw-r--r--hw/ppc/prep.c1
-rw-r--r--hw/scsi/esp-pci.c3
-rw-r--r--hw/scsi/esp.c6
-rw-r--r--hw/scsi/lsi53c895a.c10
-rw-r--r--hw/scsi/megasas.c4
-rw-r--r--hw/scsi/mptsas.c4
-rw-r--r--hw/scsi/scsi-bus.c56
-rw-r--r--hw/scsi/spapr_vscsi.c5
-rw-r--r--hw/scsi/virtio-scsi.c8
-rw-r--r--hw/sh4/r2d.c1
-rw-r--r--hw/sparc/sun4m.c5
-rw-r--r--hw/sparc64/sun4u.c2
-rw-r--r--include/hw/pci/pci.h2
-rw-r--r--include/hw/scsi/scsi.h3
-rw-r--r--include/sysemu/blockdev.h11
-rw-r--r--qemu-options.hx5
-rw-r--r--tests/qemu-iotests/051.pc.out12
-rw-r--r--vl.c10
37 files changed, 137 insertions, 97 deletions
diff --git a/blockdev.c b/blockdev.c
index db82ac97e5..bbf9d4d8f1 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -227,27 +227,30 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit)
return NULL;
}
-bool drive_check_orphaned(void)
+void drive_check_orphaned(void)
{
BlockBackend *blk;
DriveInfo *dinfo;
- bool rs = false;
+ Location loc;
+ bool orphans = false;
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
dinfo = blk_legacy_dinfo(blk);
- /* If dinfo->bdrv->dev is NULL, it has no device attached. */
- /* Unless this is a default drive, this may be an oversight. */
if (!blk_get_attached_dev(blk) && !dinfo->is_default &&
dinfo->type != IF_NONE) {
- fprintf(stderr, "Warning: Orphaned drive without device: "
- "id=%s,file=%s,if=%s,bus=%d,unit=%d\n",
- blk_name(blk), blk_bs(blk) ? blk_bs(blk)->filename : "",
- if_name[dinfo->type], dinfo->bus, dinfo->unit);
- rs = true;
+ loc_push_none(&loc);
+ qemu_opts_loc_restore(dinfo->opts);
+ error_report("machine type does not support"
+ " if=%s,bus=%d,unit=%d",
+ if_name[dinfo->type], dinfo->bus, dinfo->unit);
+ loc_pop(&loc);
+ orphans = true;
}
}
- return rs;
+ if (orphans) {
+ exit(1);
+ }
}
DriveInfo *drive_get_by_index(BlockInterfaceType type, int index)
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index d6431fd586..85405da3df 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -177,6 +177,7 @@ static void clipper_machine_init(MachineClass *mc)
{
mc->desc = "Alpha DP264/CLIPPER";
mc->init = clipper_init;
+ mc->block_default_type = IF_IDE;
mc->max_cpus = 4;
mc->is_default = 1;
}
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
index dd19ba3c99..b98e1c4a8c 100644
--- a/hw/arm/cubieboard.c
+++ b/hw/arm/cubieboard.c
@@ -71,6 +71,8 @@ static void cubieboard_init(MachineState *machine)
memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
&s->sdram);
+ /* TODO create and connect IDE devices for ide_drive_get() */
+
cubieboard_binfo.ram_size = machine->ram_size;
cubieboard_binfo.kernel_filename = machine->kernel_filename;
cubieboard_binfo.kernel_cmdline = machine->kernel_cmdline;
@@ -82,6 +84,8 @@ static void cubieboard_machine_init(MachineClass *mc)
{
mc->desc = "cubietech cubieboard";
mc->init = cubieboard_init;
+ mc->block_default_type = IF_IDE;
+ mc->units_per_default_bus = 1;
}
DEFINE_MACHINE("cubieboard", cubieboard_machine_init)
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index 80e5fd458b..0a4508cef3 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -363,6 +363,8 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 2, pic[82]);
}
+ /* TODO create and connect IDE devices for ide_drive_get() */
+
highbank_binfo.ram_size = ram_size;
highbank_binfo.kernel_filename = kernel_filename;
highbank_binfo.kernel_cmdline = kernel_cmdline;
@@ -405,7 +407,8 @@ static void highbank_class_init(ObjectClass *oc, void *data)
mc->desc = "Calxeda Highbank (ECX-1000)";
mc->init = highbank_init;
- mc->block_default_type = IF_SCSI;
+ mc->block_default_type = IF_IDE;
+ mc->units_per_default_bus = 1;
mc->max_cpus = 4;
}
@@ -421,7 +424,8 @@ static void midway_class_init(ObjectClass *oc, void *data)
mc->desc = "Calxeda Midway (ECX-2000)";
mc->init = midway_init;
- mc->block_default_type = IF_SCSI;
+ mc->block_default_type = IF_IDE;
+ mc->units_per_default_bus = 1;
mc->max_cpus = 4;
}
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 8eafccaf1d..b7d4753400 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -259,7 +259,7 @@ static void realview_init(MachineState *machine,
}
n = drive_get_max_bus(IF_SCSI);
while (n >= 0) {
- pci_create_simple(pci_bus, -1, "lsi53c895a");
+ lsi53c895a_create(pci_bus);
n--;
}
}
@@ -443,7 +443,6 @@ static void realview_pbx_a9_class_init(ObjectClass *oc, void *data)
mc->desc = "ARM RealView Platform Baseboard Explore for Cortex-A9";
mc->init = realview_pbx_a9_init;
- mc->block_default_type = IF_SCSI;
mc->max_cpus = 4;
}
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index 949a15ae64..fe2d5a764c 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -998,6 +998,7 @@ static void spitzpda_class_init(ObjectClass *oc, void *data)
mc->desc = "Sharp SL-C3000 (Spitz) PDA (PXA270)";
mc->init = spitz_init;
+ mc->block_default_type = IF_IDE;
}
static const TypeInfo spitzpda_type = {
@@ -1012,6 +1013,7 @@ static void borzoipda_class_init(ObjectClass *oc, void *data)
mc->desc = "Sharp SL-C3100 (Borzoi) PDA (PXA270)";
mc->init = borzoi_init;
+ mc->block_default_type = IF_IDE;
}
static const TypeInfo borzoipda_type = {
@@ -1026,6 +1028,7 @@ static void terrierpda_class_init(ObjectClass *oc, void *data)
mc->desc = "Sharp SL-C3200 (Terrier) PDA (PXA270)";
mc->init = terrier_init;
+ mc->block_default_type = IF_IDE;
}
static const TypeInfo terrierpda_type = {
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index c3db996930..9f58a23fb5 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -263,6 +263,7 @@ static void tosapda_machine_init(MachineClass *mc)
{
mc->desc = "Sharp SL-6000 (Tosa) PDA (PXA255)";
mc->init = tosa_init;
+ mc->block_default_type = IF_IDE;
}
DEFINE_MACHINE("tosa", tosapda_machine_init)
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 7b5cb36d5a..b0e9f5be65 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -290,7 +290,7 @@ static void versatile_init(MachineState *machine, int board_id)
}
n = drive_get_max_bus(IF_SCSI);
while (n >= 0) {
- pci_create_simple(pci_bus, -1, "lsi53c895a");
+ lsi53c895a_create(pci_bus);
n--;
}
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index e05756846e..c6b1e674b4 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -752,7 +752,6 @@ static void vexpress_class_init(ObjectClass *oc, void *data)
mc->desc = "ARM Versatile Express";
mc->init = vexpress_common_init;
- mc->block_default_type = IF_SCSI;
mc->max_cpus = 4;
}
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 7dac20d67d..3985356fc2 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -323,7 +323,6 @@ static void zynq_machine_init(MachineClass *mc)
{
mc->desc = "Xilinx Zynq Platform Baseboard for Cortex-A9";
mc->init = zynq_init;
- mc->block_default_type = IF_SCSI;
mc->max_cpus = 1;
mc->no_sdcard = 1;
}
diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c
index 4ec590a25d..860780ab8b 100644
--- a/hw/arm/xlnx-ep108.c
+++ b/hw/arm/xlnx-ep108.c
@@ -106,6 +106,8 @@ static void xlnx_ep108_init(MachineState *machine)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]), 1, cs_line);
}
+ /* TODO create and connect IDE devices for ide_drive_get() */
+
xlnx_ep108_binfo.ram_size = ram_size;
xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;
@@ -118,6 +120,8 @@ static void xlnx_ep108_machine_init(MachineClass *mc)
{
mc->desc = "Xilinx ZynqMP EP108 board";
mc->init = xlnx_ep108_init;
+ mc->block_default_type = IF_IDE;
+ mc->units_per_default_bus = 1;
}
DEFINE_MACHINE("xlnx-ep108", xlnx_ep108_machine_init)
@@ -126,6 +130,8 @@ static void xlnx_zcu102_machine_init(MachineClass *mc)
{
mc->desc = "Xilinx ZynqMP ZCU102 board";
mc->init = xlnx_ep108_init;
+ mc->block_default_type = IF_IDE;
+ mc->units_per_default_bus = 1;
}
DEFINE_MACHINE("xlnx-zcu102", xlnx_zcu102_machine_init)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e3fcd514dd..60b0946be3 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1650,9 +1650,15 @@ void pc_pci_device_init(PCIBus *pci_bus)
int max_bus;
int bus;
+ /* Note: if=scsi is deprecated with PC machine types */
max_bus = drive_get_max_bus(IF_SCSI);
for (bus = 0; bus <= max_bus; bus++) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
+ /*
+ * By not creating frontends here, we make
+ * scsi_legacy_handle_cmdline() create them, and warn that
+ * this usage is deprecated.
+ */
}
}
@@ -2339,6 +2345,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
mc->query_hotpluggable_cpus = pc_query_hotpluggable_cpus;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
+ mc->block_default_type = IF_IDE;
mc->max_cpus = 255;
mc->reset = pc_machine_reset;
hc->pre_plug = pc_machine_device_pre_plug_cb;
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 43709e545f..cfa5de6ebf 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2840,23 +2840,6 @@ const VMStateDescription vmstate_ide_bus = {
void ide_drive_get(DriveInfo **hd, int n)
{
int i;
- int highest_bus = drive_get_max_bus(IF_IDE) + 1;
- int max_devs = drive_get_max_devs(IF_IDE);
- int n_buses = max_devs ? (n / max_devs) : n;
-
- /*
- * Note: The number of actual buses available is not known.
- * We compute this based on the size of the DriveInfo* array, n.
- * If it is less than max_devs * <num_real_buses>,
- * We will stop looking for drives prematurely instead of overfilling
- * the array.
- */
-
- if (highest_bus > n_buses) {
- error_report("Too many IDE buses defined (%d > %d)",
- highest_bus, n_buses);
- exit(1);
- }
for (i = 0; i < n; i++) {
hd[i] = drive_get_by_index(IF_IDE, i);
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 9a4dae42d9..e636c3abaa 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -387,6 +387,7 @@ static void mips_fulong2e_machine_init(MachineClass *mc)
{
mc->desc = "Fulong 2e mini pc";
mc->init = mips_fulong2e_init;
+ mc->block_default_type = IF_IDE;
}
DEFINE_MACHINE("fulong2e", mips_fulong2e_machine_init)
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index 73f6c9facf..1cef581878 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -291,10 +291,6 @@ static void mips_jazz_init(MachineState *machine,
qdev_get_gpio_in(rc4030, 5), &esp_reset, &dma_enable);
/* Floppy */
- if (drive_get_max_bus(IF_FLOPPY) >= MAX_FD) {
- fprintf(stderr, "qemu: too many floppy drives\n");
- exit(1);
- }
for (n = 0; n < MAX_FD; n++) {
fds[n] = drive_get(IF_FLOPPY, 0, n);
}
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 75877de11c..5dd177e961 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -1264,6 +1264,7 @@ static void mips_malta_machine_init(MachineClass *mc)
{
mc->desc = "MIPS Malta Core LV";
mc->init = mips_malta_init;
+ mc->block_default_type = IF_IDE;
mc->max_cpus = 16;
mc->is_default = 1;
}
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index 27548c43b6..748586ed77 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -306,6 +306,7 @@ static void mips_machine_init(MachineClass *mc)
{
mc->desc = "mips r4k platform";
mc->init = mips_r4k_init;
+ mc->block_default_type = IF_IDE;
}
DEFINE_MACHINE("mips", mips_machine_init)
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 2bfdb643df..716aea6852 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -518,6 +518,7 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
mc->desc = "Mac99 based PowerMAC";
mc->init = ppc_core99_init;
+ mc->block_default_type = IF_IDE;
mc->max_cpus = MAX_CPUS;
mc->default_boot_order = "cd";
mc->kvm_type = core99_kvm_type;
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 56282c5bc6..5df94e239b 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -368,6 +368,7 @@ static void heathrow_machine_init(MachineClass *mc)
{
mc->desc = "Heathrow based PowerMAC";
mc->init = ppc_heathrow_init;
+ mc->block_default_type = IF_IDE;
mc->max_cpus = MAX_CPUS;
#ifndef TARGET_PPC64
mc->is_default = 1;
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index ca7959c126..961230c569 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -684,6 +684,7 @@ static void prep_machine_init(MachineClass *mc)
{
mc->desc = "PowerPC PREP platform";
mc->init = ppc_prep_init;
+ mc->block_default_type = IF_IDE;
mc->max_cpus = MAX_CPUS;
mc->default_boot_order = "cad";
}
diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 595f88b352..e295d88939 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -367,9 +367,6 @@ static void esp_pci_scsi_realize(PCIDevice *dev, Error **errp)
s->irq = pci_allocate_irq(dev);
scsi_bus_new(&s->bus, sizeof(s->bus), d, &esp_pci_scsi_info, NULL);
- if (!d->hotplugged) {
- scsi_bus_legacy_handle_cmdline(&s->bus, errp);
- }
}
static void esp_pci_scsi_uninit(PCIDevice *d)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 5a5a4e946a..eee831efeb 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -690,7 +690,6 @@ static void sysbus_esp_realize(DeviceState *dev, Error **errp)
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
SysBusESPState *sysbus = ESP(dev);
ESPState *s = &sysbus->esp;
- Error *err = NULL;
sysbus_init_irq(sbd, &s->irq);
assert(sysbus->it_shift != -1);
@@ -703,11 +702,6 @@ static void sysbus_esp_realize(DeviceState *dev, Error **errp)
qdev_init_gpio_in(dev, sysbus_esp_gpio_demux, 2);
scsi_bus_new(&s->bus, sizeof(s->bus), dev, &esp_scsi_info, NULL);
- scsi_bus_legacy_handle_cmdline(&s->bus, &err);
- if (err != NULL) {
- error_propagate(errp, err);
- return;
- }
}
static void sysbus_esp_hard_reset(DeviceState *dev)
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index feb1191315..595c26017a 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -2216,9 +2216,6 @@ static void lsi_scsi_realize(PCIDevice *dev, Error **errp)
QTAILQ_INIT(&s->queue);
scsi_bus_new(&s->bus, sizeof(s->bus), d, &lsi_scsi_info, NULL);
- if (!d->hotplugged) {
- scsi_bus_legacy_handle_cmdline(&s->bus, errp);
- }
}
static void lsi_scsi_unrealize(DeviceState *dev, Error **errp)
@@ -2271,3 +2268,10 @@ static void lsi53c895a_register_types(void)
}
type_init(lsi53c895a_register_types)
+
+void lsi53c895a_create(PCIBus *bus)
+{
+ LSIState *s = LSI53C895A(pci_create_simple(bus, -1, "lsi53c895a"));
+
+ scsi_bus_legacy_handle_cmdline(&s->bus, false);
+}
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 1a8b04c6d7..e3d59b7c83 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2325,7 +2325,6 @@ static const struct SCSIBusInfo megasas_scsi_info = {
static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
{
- DeviceState *d = DEVICE(dev);
MegasasState *s = MEGASAS(dev);
MegasasBaseClass *b = MEGASAS_DEVICE_GET_CLASS(s);
uint8_t *pci_conf;
@@ -2426,9 +2425,6 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
&megasas_scsi_info, NULL);
- if (!d->hotplugged) {
- scsi_bus_legacy_handle_cmdline(&s->bus, errp);
- }
}
static Property megasas_properties_gen1[] = {
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index ad87e78fe2..2e091c0156 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -1271,7 +1271,6 @@ static const struct SCSIBusInfo mptsas_scsi_info = {
static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)
{
- DeviceState *d = DEVICE(dev);
MPTSASState *s = MPT_SAS(dev);
Error *err = NULL;
int ret;
@@ -1326,9 +1325,6 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)
QTAILQ_INIT(&s->pending);
scsi_bus_new(&s->bus, sizeof(s->bus), &dev->qdev, &mptsas_scsi_info, NULL);
- if (!d->hotplugged) {
- scsi_bus_legacy_handle_cmdline(&s->bus, errp);
- }
}
static void mptsas_scsi_uninit(PCIDevice *dev)
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index c9f0ac03d5..f5574469c8 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -263,12 +263,11 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
return SCSI_DEVICE(dev);
}
-void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp)
+void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, bool deprecated)
{
Location loc;
DriveInfo *dinfo;
int unit;
- Error *err = NULL;
loc_push_none(&loc);
for (unit = 0; unit <= bus->info->max_target; unit++) {
@@ -277,16 +276,59 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp)
continue;
}
qemu_opts_loc_restore(dinfo->opts);
- scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo),
- unit, false, -1, NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
- break;
+ if (deprecated) {
+ /* Handling -drive not claimed by machine initialization */
+ if (blk_get_attached_dev(blk_by_legacy_dinfo(dinfo))) {
+ continue; /* claimed */
+ }
+ if (!dinfo->is_default) {
+ error_report("warning: bus=%d,unit=%d is deprecated with this"
+ " machine type",
+ bus->busnr, unit);
+ }
}
+ scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo),
+ unit, false, -1, NULL, &error_fatal);
}
loc_pop(&loc);
}
+static bool is_scsi_hba_with_legacy_magic(Object *obj)
+{
+ static const char *magic[] = {
+ "am53c974", "dc390", "esp", "lsi53c810", "lsi53c895a",
+ "megasas", "megasas-gen2", "mptsas1068", "spapr-vscsi",
+ "virtio-scsi-device",
+ NULL
+ };
+ const char *typename = object_get_typename(obj);
+ int i;
+
+ for (i = 0; magic[i]; i++)
+ if (!strcmp(typename, magic[i])) {
+ return true;
+ }
+
+ return false;
+}
+
+static int scsi_legacy_handle_cmdline_cb(Object *obj, void *opaque)
+{
+ SCSIBus *bus = (SCSIBus *)object_dynamic_cast(obj, TYPE_SCSI_BUS);
+
+ if (bus && is_scsi_hba_with_legacy_magic(OBJECT(bus->qbus.parent))) {
+ scsi_bus_legacy_handle_cmdline(bus, true);
+ }
+
+ return 0;
+}
+
+void scsi_legacy_handle_cmdline(void)
+{
+ object_child_foreach_recursive(object_get_root(),
+ scsi_legacy_handle_cmdline_cb, NULL);
+}
+
static int32_t scsi_invalid_field(SCSIRequest *req, uint8_t *buf)
{
scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));
diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index 6090a204a0..55ee48c4da 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -1206,9 +1206,6 @@ static void spapr_vscsi_realize(VIOsPAPRDevice *dev, Error **errp)
scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
&vscsi_scsi_info, NULL);
- if (!dev->qdev.hotplugged) {
- scsi_bus_legacy_handle_cmdline(&s->bus, errp);
- }
}
void spapr_vscsi_create(VIOsPAPRBus *bus)
@@ -1218,6 +1215,8 @@ void spapr_vscsi_create(VIOsPAPRBus *bus)
dev = qdev_create(&bus->bus, "spapr-vscsi");
qdev_init_nofail(dev);
+ scsi_bus_legacy_handle_cmdline(&VIO_SPAPR_VSCSI_DEVICE(dev)->bus,
+ false);
}
static int spapr_vscsi_devnode(VIOsPAPRDevice *dev, void *fdt, int node_off)
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 9e6f0e8305..1dbc4bced9 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -904,14 +904,6 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
/* override default SCSI bus hotplug-handler, with virtio-scsi's one */
qbus_set_hotplug_handler(BUS(&s->bus), dev, &error_abort);
- if (!dev->hotplugged) {
- scsi_bus_legacy_handle_cmdline(&s->bus, &err);
- if (err != NULL) {
- error_propagate(errp, err);
- return;
- }
- }
-
virtio_scsi_dataplane_setup(s, errp);
}
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index db373c70c5..6d06968f8b 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -362,6 +362,7 @@ static void r2d_machine_init(MachineClass *mc)
{
mc->desc = "r2d-plus board";
mc->init = r2d_init;
+ mc->block_default_type = IF_IDE;
}
DEFINE_MACHINE("r2d", r2d_machine_init)
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index f5b6efddf8..61416a6426 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -989,11 +989,6 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[30], fdc_tc);
- if (drive_get_max_bus(IF_SCSI) > 0) {
- fprintf(stderr, "qemu: too many SCSI bus\n");
- exit(1);
- }
-
esp_init(hwdef->esp_base, 2,
espdma_memory_read, espdma_memory_write,
espdma, espdma_irq, &esp_reset, &dma_enable);
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index d1a6bca873..d347b6616d 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -579,6 +579,7 @@ static void sun4u_class_init(ObjectClass *oc, void *data)
mc->desc = "Sun4u platform";
mc->init = sun4u_init;
+ mc->block_default_type = IF_IDE;
mc->max_cpus = 1; /* XXX for now */
mc->is_default = 1;
mc->default_boot_order = "c";
@@ -596,6 +597,7 @@ static void sun4v_class_init(ObjectClass *oc, void *data)
mc->desc = "Sun4v platform";
mc->init = sun4v_init;
+ mc->block_default_type = IF_IDE;
mc->max_cpus = 1; /* XXX for now */
mc->default_boot_order = "c";
}
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 05ef14b6f5..6983f13745 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -688,6 +688,8 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name);
PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);
+void lsi53c895a_create(PCIBus *bus);
+
qemu_irq pci_allocate_irq(PCIDevice *pci_dev);
void pci_set_irq(PCIDevice *pci_dev, int level);
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index 9bad49e917..6b85786dbf 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -177,7 +177,8 @@ static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
int unit, bool removable, int bootindex,
const char *serial, Error **errp);
-void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp);
+void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, bool deprecated);
+void scsi_legacy_handle_cmdline(void);
/*
* Predefined sense codes
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index 16432f3508..ac22f2ae1f 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -19,12 +19,11 @@ void blockdev_auto_del(BlockBackend *blk);
typedef enum {
IF_DEFAULT = -1, /* for use with drive_add() only */
/*
- * IF_IDE must be zero, because we want MachineClass member
- * block_default_type to default-initialize to IF_IDE
+ * IF_NONE must be zero, because we want MachineClass member
+ * block_default_type to default-initialize to IF_NONE
*/
- IF_IDE = 0,
- IF_NONE,
- IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
+ IF_NONE = 0,
+ IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
IF_COUNT
} BlockInterfaceType;
@@ -49,7 +48,7 @@ BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo);
void override_max_devs(BlockInterfaceType type, int max_devs);
DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
-bool drive_check_orphaned(void);
+void drive_check_orphaned(void);
DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
int drive_get_max_bus(BlockInterfaceType type);
int drive_get_max_devs(BlockInterfaceType type);
diff --git a/qemu-options.hx b/qemu-options.hx
index 809b2b0d8c..1e815ef520 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -654,11 +654,6 @@ If you don't specify the "file=" argument, you define an empty drive:
qemu-system-i386 -drive if=ide,index=1,media=cdrom
@end example
-You can connect a SCSI disk with unit ID 6 on the bus #0:
-@example
-qemu-system-i386 -drive file=file,if=scsi,bus=0,unit=6
-@end example
-
Instead of @option{-fda}, @option{-fdb}, you can use:
@example
qemu-system-i386 -drive file=file,index=0,if=floppy
diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
index 603bb768d6..f8047a2e45 100644
--- a/tests/qemu-iotests/051.pc.out
+++ b/tests/qemu-iotests/051.pc.out
@@ -118,7 +118,8 @@ QEMU X.Y.Z monitor - type 'help' for more information
Testing: -drive if=scsi,media=cdrom
QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+(qemu) QEMU_PROG: -drive if=scsi,media=cdrom: warning: bus=0,unit=0 is deprecated with this machine type
+qququiquit
Testing: -drive if=ide
QEMU X.Y.Z monitor - type 'help' for more information
@@ -127,7 +128,8 @@ QEMU_PROG: Initialization of device ide-hd failed: Device initialization failed.
Testing: -drive if=scsi
QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: Initialization of device lsi53c895a failed: Device needs media, but drive is empty
+(qemu) QEMU_PROG: -drive if=scsi: warning: bus=0,unit=0 is deprecated with this machine type
+QEMU_PROG: -drive if=scsi: Device needs media, but drive is empty
Testing: -drive if=virtio
QEMU X.Y.Z monitor - type 'help' for more information
@@ -172,7 +174,8 @@ QEMU X.Y.Z monitor - type 'help' for more information
Testing: -drive file=TEST_DIR/t.qcow2,if=scsi,media=cdrom,readonly=on
QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+(qemu) QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=scsi,media=cdrom,readonly=on: warning: bus=0,unit=0 is deprecated with this machine type
+qququiquit
Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
QEMU X.Y.Z monitor - type 'help' for more information
@@ -181,7 +184,8 @@ QEMU_PROG: Initialization of device ide-hd failed: Device initialization failed.
Testing: -drive file=TEST_DIR/t.qcow2,if=scsi,readonly=on
QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) qququiquit
+(qemu) QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=scsi,readonly=on: warning: bus=0,unit=0 is deprecated with this machine type
+qququiquit
Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
QEMU X.Y.Z monitor - type 'help' for more information
diff --git a/vl.c b/vl.c
index 27d982981a..b5d0a19811 100644
--- a/vl.c
+++ b/vl.c
@@ -62,6 +62,7 @@ int main(int argc, char **argv)
#include "hw/usb.h"
#include "hw/i386/pc.h"
#include "hw/isa/isa.h"
+#include "hw/scsi/scsi.h"
#include "hw/bt.h"
#include "sysemu/watchdog.h"
#include "hw/smbios/smbios.h"
@@ -4509,6 +4510,15 @@ int main(int argc, char **argv, char **envp)
rom_reset_order_override();
+ /*
+ * Create frontends for -drive if=scsi leftovers.
+ * Normally, frontends for -drive get created by machine
+ * initialization for onboard SCSI HBAs. However, we create a few
+ * more ever since SCSI qdevification, but this is pretty much an
+ * implementation accident, and deprecated.
+ */
+ scsi_legacy_handle_cmdline();
+
/* Did we create any drives that we failed to create a device for? */
drive_check_orphaned();