]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
hw: Deprecate -drive if=scsi with non-onboard HBAs
authorMarkus Armbruster <armbru@redhat.com>
Wed, 15 Feb 2017 12:18:55 +0000 (13:18 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 21 Feb 2017 12:17:45 +0000 (13:17 +0100)
Block backends defined with "-drive if=T" with T other than "none" are
meant to be picked up by machine initialization code: a suitable
frontend gets created and wired up automatically.

Drives defined with if=scsi are also picked up by SCSI HBAs added with
-device, unlike other interface types.  Deprecate this usage, as follows.

Create the frontends for onboard HBAs in machine initialization code,
exactly like we do for if=ide and other interface types.  Change
scsi_legacy_handle_cmdline() to create a frontend only when it's still
missing, and warn that this usage is deprecated.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1487161136-9018-3-git-send-email-armbru@redhat.com>

hw/arm/realview.c
hw/arm/versatilepb.c
hw/i386/pc.c
hw/scsi/lsi53c895a.c
hw/scsi/scsi-bus.c
hw/scsi/spapr_vscsi.c
include/hw/pci/pci.h
include/hw/scsi/scsi.h
vl.c

index 8c11c7ae777b44f8d5af493a4395740eed04a314..b7d475340056e1426f320ba64eed304da53157c6 100644 (file)
@@ -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--;
         }
     }
index 7b5cb36d5ac13552027cc23f3fa330b44622851b..b0e9f5be65233e0b7ff1df7030285e84e8a6c758 100644 (file)
@@ -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--;
     }
 
index a555c35d913f3d661355f889915956bdeca03cb0..c2c75e23da7405ef5b21cfb82bf53a1ade3d368e 100644 (file)
@@ -1652,7 +1652,7 @@ void pc_pci_device_init(PCIBus *pci_bus)
 
     max_bus = drive_get_max_bus(IF_SCSI);
     for (bus = 0; bus <= max_bus; bus++) {
-        pci_create_simple(pci_bus, -1, "lsi53c895a");
+        lsi53c895a_create(pci_bus);
     }
 }
 
index 292fa8795fa199733f79189dbf69c3f9c82ab481..595c26017ac14dcddc437a670826b67bbc82e2fb 100644 (file)
@@ -2268,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);
+}
index b9111eea1ed807f631d219c03a1c82231798f361..8cc80bf1771111ad26ffdc0d20f6004b9d6312b6 100644 (file)
@@ -261,7 +261,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
     return SCSI_DEVICE(dev);
 }
 
-void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
+void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, bool deprecated)
 {
     Location loc;
     DriveInfo *dinfo;
@@ -274,6 +274,17 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
             continue;
         }
         qemu_opts_loc_restore(dinfo->opts);
+        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);
     }
@@ -304,7 +315,7 @@ 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);
+        scsi_bus_legacy_handle_cmdline(bus, true);
     }
 
     return 0;
index 7d447718eb951ac799de68a3d68322f9bd22e8af..55ee48c4dad5a6ea0f350d0b9d25963988212c45 100644 (file)
@@ -1215,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)
index 05ef14b6f5ec9baeb05858f7212ce8139be10e30..6983f13745a54b83cf1de0d42b21c9625eb492d2 100644 (file)
@@ -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);
 
index eeef949b6625a1489e33bafdffdfc22618776351..6b85786dbf6fb9f04a86ea1c603181bf76892603 100644 (file)
@@ -177,7 +177,7 @@ 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);
+void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, bool deprecated);
 void scsi_legacy_handle_cmdline(void);
 
 /*
diff --git a/vl.c b/vl.c
index ab40889ad66ea5d12aa6f6c3f1f0132fe0719ce1..b5d0a19811e0909e30df1c87548c5a6aa4551ab3 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4510,7 +4510,13 @@ int main(int argc, char **argv, char **envp)
 
     rom_reset_order_override();
 
-    /* Create frontends for -drive if=scsi */
+    /*
+     * 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? */