From nobody Sat Apr 27 14:44:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487161476667504.6105361113513; Wed, 15 Feb 2017 04:24:36 -0800 (PST) Received: from localhost ([::1]:40112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdydP-0003oQ-BM for importer@patchew.org; Wed, 15 Feb 2017 07:24:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdyY6-0008Uh-Az for qemu-devel@nongnu.org; Wed, 15 Feb 2017 07:19:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdyY4-0000Zn-Uk for qemu-devel@nongnu.org; Wed, 15 Feb 2017 07:19:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdyXz-0000Un-W3; Wed, 15 Feb 2017 07:19:00 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3C9C61BB5; Wed, 15 Feb 2017 12:18:59 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1FCIvvh022616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 15 Feb 2017 07:18:59 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 624C011384AC; Wed, 15 Feb 2017 13:18:56 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 15 Feb 2017 13:18:54 +0100 Message-Id: <1487161136-9018-2-git-send-email-armbru@redhat.com> In-Reply-To: <1487161136-9018-1-git-send-email-armbru@redhat.com> References: <1487161136-9018-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 15 Feb 2017 12:18:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/3] hw/scsi: Concentrate -drive if=scsi auto-create in one place X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, qemu-block@nongnu.org, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The logic to create frontends for -drive if=3Dscsi 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. Signed-off-by: Markus Armbruster --- 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(-) diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index 595f88b..e295d88 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 =3D pci_allocate_irq(dev); =20 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); - } } =20 static void esp_pci_scsi_uninit(PCIDevice *d) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 5a5a4e9..eee831e 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 =3D SYS_BUS_DEVICE(dev); SysBusESPState *sysbus =3D ESP(dev); ESPState *s =3D &sysbus->esp; - Error *err =3D NULL; =20 sysbus_init_irq(sbd, &s->irq); assert(sysbus->it_shift !=3D -1); @@ -703,11 +702,6 @@ static void sysbus_esp_realize(DeviceState *dev, Error= **errp) qdev_init_gpio_in(dev, sysbus_esp_gpio_demux, 2); =20 scsi_bus_new(&s->bus, sizeof(s->bus), dev, &esp_scsi_info, NULL); - scsi_bus_legacy_handle_cmdline(&s->bus, &err); - if (err !=3D NULL) { - error_propagate(errp, err); - return; - } } =20 static void sysbus_esp_hard_reset(DeviceState *dev) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index feb1191..292fa87 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); =20 scsi_bus_new(&s->bus, sizeof(s->bus), d, &lsi_scsi_info, NULL); - if (!d->hotplugged) { - scsi_bus_legacy_handle_cmdline(&s->bus, errp); - } } =20 static void lsi_scsi_unrealize(DeviceState *dev, Error **errp) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 1a8b04c..e3d59b7 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -2325,7 +2325,6 @@ static const struct SCSIBusInfo megasas_scsi_info =3D= { =20 static void megasas_scsi_realize(PCIDevice *dev, Error **errp) { - DeviceState *d =3D DEVICE(dev); MegasasState *s =3D MEGASAS(dev); MegasasBaseClass *b =3D MEGASAS_DEVICE_GET_CLASS(s); uint8_t *pci_conf; @@ -2426,9 +2425,6 @@ static void megasas_scsi_realize(PCIDevice *dev, Erro= r **errp) =20 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); - } } =20 static Property megasas_properties_gen1[] =3D { diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c index ad87e78..2e091c0 100644 --- a/hw/scsi/mptsas.c +++ b/hw/scsi/mptsas.c @@ -1271,7 +1271,6 @@ static const struct SCSIBusInfo mptsas_scsi_info =3D { =20 static void mptsas_scsi_realize(PCIDevice *dev, Error **errp) { - DeviceState *d =3D DEVICE(dev); MPTSASState *s =3D MPT_SAS(dev); Error *err =3D NULL; int ret; @@ -1326,9 +1325,6 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error= **errp) QTAILQ_INIT(&s->pending); =20 scsi_bus_new(&s->bus, sizeof(s->bus), &dev->qdev, &mptsas_scsi_info, N= ULL); - if (!d->hotplugged) { - scsi_bus_legacy_handle_cmdline(&s->bus, errp); - } } =20 static void mptsas_scsi_uninit(PCIDevice *dev) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 5940cb1..b9111ee 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -261,12 +261,11 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, B= lockBackend *blk, return SCSI_DEVICE(dev); } =20 -void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp) +void scsi_bus_legacy_handle_cmdline(SCSIBus *bus) { Location loc; DriveInfo *dinfo; int unit; - Error *err =3D NULL; =20 loc_push_none(&loc); for (unit =3D 0; unit <=3D bus->info->max_target; unit++) { @@ -276,15 +275,47 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Err= or **errp) } qemu_opts_loc_restore(dinfo->opts); scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo), - unit, false, -1, NULL, &err); - if (err !=3D NULL) { - error_propagate(errp, err); - break; - } + unit, false, -1, NULL, &error_fatal); } loc_pop(&loc); } =20 +static bool is_scsi_hba_with_legacy_magic(Object *obj) +{ + static const char *magic[] =3D { + "am53c974", "dc390", "esp", "lsi53c810", "lsi53c895a", + "megasas", "megasas-gen2", "mptsas1068", "spapr-vscsi", + "virtio-scsi-device", + NULL + }; + const char *typename =3D object_get_typename(obj); + int i; + + for (i =3D 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 =3D (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); + } + + 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 6090a20..7d44771 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) =20 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); - } } =20 void spapr_vscsi_create(VIOsPAPRBus *bus) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index ce19eff..5629f97 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -889,14 +889,6 @@ static void virtio_scsi_device_realize(DeviceState *de= v, Error **errp) /* override default SCSI bus hotplug-handler, with virtio-scsi's one */ qbus_set_hotplug_handler(BUS(&s->bus), dev, &error_abort); =20 - if (!dev->hotplugged) { - scsi_bus_legacy_handle_cmdline(&s->bus, &err); - if (err !=3D NULL) { - error_propagate(errp, err); - return; - } - } - virtio_scsi_dataplane_setup(s, errp); } =20 diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 9bad49e..eeef949 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 bootin= dex, 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); =20 /* * Predefined sense codes diff --git a/vl.c b/vl.c index b4eaf03..94a34da 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" @@ -4521,6 +4522,9 @@ int main(int argc, char **argv, char **envp) =20 rom_reset_order_override(); =20 + /* Create frontends for -drive if=3Dscsi */ + scsi_legacy_handle_cmdline(); + /* Did we create any drives that we failed to create a device for? */ drive_check_orphaned(); =20 --=20 2.7.4 From nobody Sat Apr 27 14:44:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487161257537869.2447793174928; Wed, 15 Feb 2017 04:20:57 -0800 (PST) Received: from localhost ([::1]:40097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdyZr-00012k-SW for importer@patchew.org; Wed, 15 Feb 2017 07:20:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdyY5-0008UH-QP for qemu-devel@nongnu.org; Wed, 15 Feb 2017 07:19:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdyY4-0000ZT-J1 for qemu-devel@nongnu.org; Wed, 15 Feb 2017 07:19:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43624) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdyY0-0000Uq-0X; Wed, 15 Feb 2017 07:19:00 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1EF13A7683; Wed, 15 Feb 2017 12:18:59 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1FCIvtM010226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 15 Feb 2017 07:18:59 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 64C4411384AE; Wed, 15 Feb 2017 13:18:56 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 15 Feb 2017 13:18:55 +0100 Message-Id: <1487161136-9018-3-git-send-email-armbru@redhat.com> In-Reply-To: <1487161136-9018-1-git-send-email-armbru@redhat.com> References: <1487161136-9018-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 15 Feb 2017 12:18:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/3] hw: Deprecate -drive if=scsi with non-onboard HBAs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, qemu-block@nongnu.org, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Block backends defined with "-drive if=3DT" 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=3Dscsi 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=3Dide 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 --- 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 | 15 +++++++++++++-- hw/scsi/spapr_vscsi.c | 2 ++ include/hw/pci/pci.h | 2 ++ include/hw/scsi/scsi.h | 2 +- vl.c | 8 +++++++- 9 files changed, 35 insertions(+), 7 deletions(-) diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 8c11c7a..b7d4753 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -259,7 +259,7 @@ static void realview_init(MachineState *machine, } n =3D drive_get_max_bus(IF_SCSI); while (n >=3D 0) { - pci_create_simple(pci_bus, -1, "lsi53c895a"); + lsi53c895a_create(pci_bus); n--; } } diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index 7b5cb36..b0e9f5b 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -290,7 +290,7 @@ static void versatile_init(MachineState *machine, int b= oard_id) } n =3D drive_get_max_bus(IF_SCSI); while (n >=3D 0) { - pci_create_simple(pci_bus, -1, "lsi53c895a"); + lsi53c895a_create(pci_bus); n--; } =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index a555c35..c2c75e2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1652,7 +1652,7 @@ void pc_pci_device_init(PCIBus *pci_bus) =20 max_bus =3D drive_get_max_bus(IF_SCSI); for (bus =3D 0; bus <=3D max_bus; bus++) { - pci_create_simple(pci_bus, -1, "lsi53c895a"); + lsi53c895a_create(pci_bus); } } =20 diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 292fa87..595c260 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -2268,3 +2268,10 @@ static void lsi53c895a_register_types(void) } =20 type_init(lsi53c895a_register_types) + +void lsi53c895a_create(PCIBus *bus) +{ + LSIState *s =3D LSI53C895A(pci_create_simple(bus, -1, "lsi53c895a")); + + scsi_bus_legacy_handle_cmdline(&s->bus, false); +} diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index b9111ee..8cc80bf 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -261,7 +261,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, Blo= ckBackend *blk, return SCSI_DEVICE(dev); } =20 -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=3D%d,unit=3D%d is deprecated wi= th 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, v= oid *opaque) SCSIBus *bus =3D (SCSIBus *)object_dynamic_cast(obj, TYPE_SCSI_BUS); =20 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); } =20 return 0; diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 7d44771..55ee48c 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -1215,6 +1215,8 @@ void spapr_vscsi_create(VIOsPAPRBus *bus) dev =3D qdev_create(&bus->bus, "spapr-vscsi"); =20 qdev_init_nofail(dev); + scsi_bus_legacy_handle_cmdline(&VIO_SPAPR_VSCSI_DEVICE(dev)->bus, + false); } =20 static int spapr_vscsi_devnode(VIOsPAPRDevice *dev, void *fdt, int node_of= f) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index cbc1fdf..24435d7 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -687,6 +687,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); =20 +void lsi53c895a_create(PCIBus *bus); + qemu_irq pci_allocate_irq(PCIDevice *pci_dev); void pci_set_irq(PCIDevice *pci_dev, int level); =20 diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index eeef949..6b85786 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -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 bootin= dex, 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); =20 /* diff --git a/vl.c b/vl.c index 94a34da..449e30c 100644 --- a/vl.c +++ b/vl.c @@ -4522,7 +4522,13 @@ int main(int argc, char **argv, char **envp) =20 rom_reset_order_override(); =20 - /* Create frontends for -drive if=3Dscsi */ + /* + * Create frontends for -drive if=3Dscsi 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(); =20 /* Did we create any drives that we failed to create a device for? */ --=20 2.7.4 From nobody Sat Apr 27 14:44:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487161476593454.68212242700633; Wed, 15 Feb 2017 04:24:36 -0800 (PST) Received: from localhost ([::1]:40111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdydP-0003o9-7h for importer@patchew.org; Wed, 15 Feb 2017 07:24:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdyY5-0008UF-Ol for qemu-devel@nongnu.org; Wed, 15 Feb 2017 07:19:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdyY4-0000ZZ-KK for qemu-devel@nongnu.org; Wed, 15 Feb 2017 07:19:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34198) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdyXz-0000Ul-W6; Wed, 15 Feb 2017 07:19:00 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADD01C0567B3; Wed, 15 Feb 2017 12:18:59 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1FCIv8T010230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 15 Feb 2017 07:18:59 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6784C11384AF; Wed, 15 Feb 2017 13:18:56 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 15 Feb 2017 13:18:56 +0100 Message-Id: <1487161136-9018-4-git-send-email-armbru@redhat.com> In-Reply-To: <1487161136-9018-1-git-send-email-armbru@redhat.com> References: <1487161136-9018-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 15 Feb 2017 12:18:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/3] hw/i386: Deprecate -drive if=scsi with PC machine types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pbonzini@redhat.com, mreitz@redhat.com, qemu-block@nongnu.org, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The PC machines (pc-q35-* pc-i440fx-* pc-* isapc xenfv) automatically create lsi53c895a SCSI HBAs and SCSI devices to honor -drive if=3Dscsi. For giggles, try -drive if=3Dscsi,bus=3D25,media=3Dcdrom --- 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=3Dscsi. Signed-off-by: Markus Armbruster --- hw/i386/pc.c | 8 +++++++- qemu-options.hx | 5 ----- tests/qemu-iotests/051.pc.out | 12 ++++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c2c75e2..60b0946 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; =20 + /* Note: if=3Dscsi is deprecated with PC machine types */ max_bus =3D drive_get_max_bus(IF_SCSI); for (bus =3D 0; bus <=3D 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. + */ } } =20 diff --git a/qemu-options.hx b/qemu-options.hx index ac036b4..f41cc18 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -654,11 +654,6 @@ If you don't specify the "file=3D" argument, you defin= e an empty drive: qemu-system-i386 -drive if=3Dide,index=3D1,media=3Dcdrom @end example =20 -You can connect a SCSI disk with unit ID 6 on the bus #0: -@example -qemu-system-i386 -drive file=3Dfile,if=3Dscsi,bus=3D0,unit=3D6 -@end example - Instead of @option{-fda}, @option{-fdb}, you can use: @example qemu-system-i386 -drive file=3Dfile,index=3D0,if=3Dfloppy diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out index 603bb76..f8047a2 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 =20 Testing: -drive if=3Dscsi,media=3Dcdrom QEMU X.Y.Z monitor - type 'help' for more information -(qemu) q=1B[K=1B[Dqu=1B[K=1B[D=1B[Dqui=1B[K=1B[D=1B[D=1B[Dquit=1B[K +(qemu) QEMU_PROG: -drive if=3Dscsi,media=3Dcdrom: warning: bus=3D0,unit=3D= 0 is deprecated with this machine type +q=1B[K=1B[Dqu=1B[K=1B[D=1B[Dqui=1B[K=1B[D=1B[D=1B[Dquit=1B[K =20 Testing: -drive if=3Dide QEMU X.Y.Z monitor - type 'help' for more information @@ -127,7 +128,8 @@ QEMU_PROG: Initialization of device ide-hd failed: Devi= ce initialization failed. =20 Testing: -drive if=3Dscsi 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=3Dscsi: warning: bus=3D0,unit=3D0 is deprecate= d with this machine type +QEMU_PROG: -drive if=3Dscsi: Device needs media, but drive is empty =20 Testing: -drive if=3Dvirtio QEMU X.Y.Z monitor - type 'help' for more information @@ -172,7 +174,8 @@ QEMU X.Y.Z monitor - type 'help' for more information =20 Testing: -drive file=3DTEST_DIR/t.qcow2,if=3Dscsi,media=3Dcdrom,readonly= =3Don QEMU X.Y.Z monitor - type 'help' for more information -(qemu) q=1B[K=1B[Dqu=1B[K=1B[D=1B[Dqui=1B[K=1B[D=1B[D=1B[Dquit=1B[K +(qemu) QEMU_PROG: -drive file=3DTEST_DIR/t.qcow2,if=3Dscsi,media=3Dcdrom,r= eadonly=3Don: warning: bus=3D0,unit=3D0 is deprecated with this machine type +q=1B[K=1B[Dqu=1B[K=1B[D=1B[Dqui=1B[K=1B[D=1B[D=1B[Dquit=1B[K =20 Testing: -drive file=3DTEST_DIR/t.qcow2,if=3Dide,readonly=3Don QEMU X.Y.Z monitor - type 'help' for more information @@ -181,7 +184,8 @@ QEMU_PROG: Initialization of device ide-hd failed: Devi= ce initialization failed. =20 Testing: -drive file=3DTEST_DIR/t.qcow2,if=3Dscsi,readonly=3Don QEMU X.Y.Z monitor - type 'help' for more information -(qemu) q=1B[K=1B[Dqu=1B[K=1B[D=1B[Dqui=1B[K=1B[D=1B[D=1B[Dquit=1B[K +(qemu) QEMU_PROG: -drive file=3DTEST_DIR/t.qcow2,if=3Dscsi,readonly=3Don: = warning: bus=3D0,unit=3D0 is deprecated with this machine type +q=1B[K=1B[Dqu=1B[K=1B[D=1B[Dqui=1B[K=1B[D=1B[D=1B[Dquit=1B[K =20 Testing: -drive file=3DTEST_DIR/t.qcow2,if=3Dvirtio,readonly=3Don QEMU X.Y.Z monitor - type 'help' for more information --=20 2.7.4