hw: Deprecate unwanted use -drive if=scsi
PATCH 3/3 hw/i386: Deprecate -drive if=scsi with PC machine types
In reply to Markus ArmbrusterThe PC machines (pc-q35-* pc-i440fx-* pc-* isapc xenfv) automatically create lsi53c895a SCSI HBAs and SCSI devices to honor -drive if=scsi. For giggles, try -drive if=scsi,bus=25,media=cdrom --- this makes QEMU create 25 of them.
lsi53c895a is thoroughly obsolete (PCI Ultra2 SCSI, ca. 2000), and currently has no maintainer in QEMU. megasas is a better choice, except with old OSes that lack drivers. virtio-scsi is a much better choice when you have a driver, but only (newish) Linux comes with one in the box. There is no good default that works for all guests.
Encourage users to pick a non-obsolete SCSI HBA that works for them by deprecating -drive if=scsi.
--- hw/i386/pc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/i386/pc.c +7 -1
@@ -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++) { -lsi53c895a_create (pci_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. +*/ } }
Signature · 1 line
2.7.4
cover hw: Deprecate unwanted use -drive if=scsi
Drives defined with if=scsi get connected to buses created with -device, unlike other interface types. Deprecate this usage.
There is no good default SCSI HBA for PC machines. Deprecate if=scsi there entirely.
Before this series, frontends for -drive if=scsi get created by SCSI HBAs. Frontends for other interface types get created by machine initialization.
After this series, they get created by machine initialization, except for deprecated cases, which get created by new function scsi_legacy_handle_cmdline().
Based on "[PATCH v2 0/8] More sensible default for -drive interface type".
Markus Armbruster (3):
hw/scsi: Concentrate -drive if=scsi auto-create in one place
hw: Deprecate -drive if=scsi with non-onboard HBAs hw/i386: Deprecate -drive if=scsi with PC machine types
hw/arm/realview.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/i386/pc.c | 6 ++++++ hw/scsi/esp-pci.c | 3 --- hw/scsi/esp.c | 6 ------ hw/scsi/lsi53c895a.c | 10 +++++++--- hw/scsi/megasas.c | 4 ---- hw/scsi/mptsas.c | 4 ---- hw/scsi/scsi-bus.c | 54 +++++++++++++++++++++++++++++++++++++++++++------- hw/scsi/spapr_vscsi.c | 5 ++--- hw/scsi/virtio-scsi.c | 8 -------- include/hw/pci/pci.h | 2 ++ include/hw/scsi/scsi.h | 3 ++- vl.c | 10 ++++++++++ 14 files changed, 78 insertions(+), 41 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 hw/scsi: Concentrate -drive if=scsi auto-create in one place
The logic to create frontends for -drive if=scsi is in SCSI HBAs. For all other interface types, it's in machine initialization code.
A few machine types create the SCSI HBAs necessary for that. That's also not done for other interface types.
I'm going to deprecate these SCSI eccentricities. In preparation for that, create the frontends in main() instead of the SCSI HBAs, by calling new function scsi_legacy_handle_cmdline() there.
Note that not all SCSI HBAs create frontends. Take care not to change that.
--- hw/scsi/esp-pci.c | 3 --- hw/scsi/esp.c | 6 ------ hw/scsi/lsi53c895a.c | 3 --- hw/scsi/megasas.c | 4 ---- hw/scsi/mptsas.c | 4 ---- hw/scsi/scsi-bus.c | 45 ++++++++++++++++++++++++++++++++++++++------- hw/scsi/spapr_vscsi.c | 3 --- hw/scsi/virtio-scsi.c | 8 -------- include/hw/scsi/scsi.h | 3 ++- vl.c | 4 ++++ 10 files changed, 44 insertions(+), 39 deletions(-)
hw/scsi/esp-pci.c +0 -3
@@ -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)
hw/scsi/esp.c +0 -6
@@ -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)
hw/scsi/lsi53c895a.c +0 -3
@@ -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)
hw/scsi/megasas.c +0 -4
@@ -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;
@@ -2424,9 +2423,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[] = {
hw/scsi/mptsas.c +0 -4
@@ -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)
hw/scsi/scsi-bus.c +38 -7
65 lines not on this page · raw message
hw/scsi/spapr_vscsi.c +0 -3
@@ -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)
hw/scsi/virtio-scsi.c +0 -8
@@ -889,14 +889,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); }
include/hw/scsi/scsi.h +2 -1
@@ -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); +void scsi_legacy_handle_cmdline (void );/* * Predefined sense codes
vl.c +4 -0
@@ -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"
@@ -4556,6 +4557,9 @@ int main(int argc, char **argv, char **envp)rom_reset_order_override (); +/* Create frontends for -drive if=scsi */ +scsi_legacy_handle_cmdline (); +/* Did we create any drives that we failed to create a device for? */ drive_check_orphaned ();
Signature · 1 line
2.7.4
PATCH 2/3 hw: Deprecate -drive if=scsi with non-onboard HBAs
In reply to Markus ArmbrusterBlock 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.
--- hw/arm/realview.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/i386/pc.c | 2 +- hw/scsi/lsi53c895a.c | 7 +++++++ hw/scsi/scsi-bus.c | 13 +++++++++++-- hw/scsi/spapr_vscsi.c | 2 ++ include/hw/pci/pci.h | 2 ++ include/hw/scsi/scsi.h | 2 +- vl.c | 8 +++++++- 9 files changed, 33 insertions(+), 7 deletions(-)
hw/arm/realview.c +1 -1
@@ -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--; } }
hw/arm/versatilepb.c +1 -1
@@ -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--; }
hw/i386/pc.c +1 -1
@@ -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); } }
hw/scsi/lsi53c895a.c +7 -0
@@ -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); +}
hw/scsi/scsi-bus.c +11 -2
@@ -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,15 @@ 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 */ + } +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 +313,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 ;
hw/scsi/spapr_vscsi.c +2 -0
@@ -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)
include/hw/pci/pci.h +2 -0
@@ -686,6 +686,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);
include/hw/scsi/scsi.h +1 -1
@@ -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 );/*
vl.c +7 -1
@@ -4557,7 +4557,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? */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 3/3] hw/i386: Deprecate -drive if=scsi with PC machine types
In reply to Markus ArmbrusterQuoted 11 lines · Markus Armbruster
The PC machines (pc-q35-* pc-i440fx-* pc-* isapc xenfv) automatically create lsi53c895a SCSI HBAs and SCSI devices to honor -drive if=scsi. For giggles, try -drive if=scsi,bus=25,media=cdrom --- this makes QEMU create 25 of them.
lsi53c895a is thoroughly obsolete (PCI Ultra2 SCSI, ca. 2000), and currently has no maintainer in QEMU. megasas is a better choice, except with old OSes that lack drivers. virtio-scsi is a much better choice when you have a driver, but only (newish) Linux comes with one in the box. There is no good default that works for all guests.
Quoted 4 lines
Encourage users to pick a non-obsolete SCSI HBA that works for them by deprecating -drive if=scsi.
Signed-off-by Markus Armbruster <[email protected]>
Missing: update doc (qemu-options.hx), and possibly qemu-iotests/051. Will fix.