From patchwork Tue Feb 21 12:34:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 9584481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ACB25600C1 for ; Tue, 21 Feb 2017 12:50:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A48C428676 for ; Tue, 21 Feb 2017 12:50:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96CC628913; Tue, 21 Feb 2017 12:50:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BADB8288AE for ; Tue, 21 Feb 2017 12:50:02 +0000 (UTC) Received: from localhost ([::1]:44235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cg9tJ-0004EY-Nt for patchwork-qemu-devel@patchwork.kernel.org; Tue, 21 Feb 2017 07:50:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cg9eZ-0007ea-8p for qemu-devel@nongnu.org; Tue, 21 Feb 2017 07:34:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cg9eW-00083f-9G for qemu-devel@nongnu.org; Tue, 21 Feb 2017 07:34:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cg9eW-000833-0s for qemu-devel@nongnu.org; Tue, 21 Feb 2017 07:34:44 -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 37E014E33C for ; Tue, 21 Feb 2017 12:34:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LCYgnm026913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 21 Feb 2017 07:34:43 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E8D1411385F0; Tue, 21 Feb 2017 13:34:39 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 21 Feb 2017 13:34:38 +0100 Message-Id: <1487680479-15132-11-git-send-email-armbru@redhat.com> In-Reply-To: <1487680479-15132-1-git-send-email-armbru@redhat.com> References: <1487680479-15132-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.38]); Tue, 21 Feb 2017 12:34:44 +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] [PULL 10/11] 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Message-Id: <1487161136-9018-3-git-send-email-armbru@redhat.com> --- 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 = 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/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 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/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) 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); } } 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) } 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/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, 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; 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 = 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/include/hw/pci/pci.h b/include/hw/pci/pci.h index 05ef14b..6983f13 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 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 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 ab40889..b5d0a19 100644 --- 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? */