From patchwork Tue Oct 13 11:59:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 35851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 18ABAB7B8A for ; Tue, 13 Oct 2009 23:00:48 +1100 (EST) Received: from localhost ([127.0.0.1]:54987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mxg3Y-0002Nh-So for incoming@patchwork.ozlabs.org; Tue, 13 Oct 2009 08:00:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mxg2v-0002N5-BC for qemu-devel@nongnu.org; Tue, 13 Oct 2009 08:00:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mxg2q-0002M8-FO for qemu-devel@nongnu.org; Tue, 13 Oct 2009 08:00:04 -0400 Received: from [199.232.76.173] (port=45957 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mxg2q-0002Ls-BL for qemu-devel@nongnu.org; Tue, 13 Oct 2009 08:00:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1025) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mxg2p-0002cb-GR for qemu-devel@nongnu.org; Tue, 13 Oct 2009 07:59:59 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9DBxwLw009405 for ; Tue, 13 Oct 2009 07:59:58 -0400 Received: from zweiblum.home.kraxel.org (vpn1-5-43.ams2.redhat.com [10.36.5.43]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n9DBxuoX013339; Tue, 13 Oct 2009 07:59:57 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 1E02D700FA; Tue, 13 Oct 2009 13:59:55 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 13 Oct 2009 13:59:55 +0200 Message-Id: <1255435195-27832-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH] hotplug: fix "pci_add storage if=scsi" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Explicitly add the drive to the bus of the newly created scsi adapter instead of hoping that scsi_bus_legacy_handle_cmdline() picks it up correctly. Signed-off-by: Gerd Hoffmann --- hw/lsi53c895a.c | 4 +++- hw/pci-hotplug.c | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index a4d3a57..012aaf6 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -2178,7 +2178,9 @@ static int lsi_scsi_init(PCIDevice *dev) lsi_soft_reset(s); scsi_bus_new(&s->bus, &dev->qdev, 1, LSI_MAX_DEVS, lsi_command_complete); - scsi_bus_legacy_handle_cmdline(&s->bus); + if (!dev->qdev.hotplugged) { + scsi_bus_legacy_handle_cmdline(&s->bus); + } register_savevm("lsiscsi", -1, 0, lsi_scsi_save, lsi_scsi_load, s); return 0; } diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 08b5826..2a192d3 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -159,7 +159,18 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, switch (type) { case IF_SCSI: + if (!dinfo) { + monitor_printf(mon, "scsi requires a backing file/device.\n"); + return NULL; + } dev = pci_create(bus, devfn, "lsi53c895a"); + if (qdev_init(&dev->qdev) < 0) + dev = NULL; + if (dev) { + BusState *scsibus = QLIST_FIRST(&dev->qdev.child_bus); + scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus), + dinfo, dinfo->unit); + } break; case IF_VIRTIO: if (!dinfo) { @@ -168,12 +179,12 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, } dev = pci_create(bus, devfn, "virtio-blk-pci"); qdev_prop_set_drive(&dev->qdev, "drive", dinfo); + if (qdev_init(&dev->qdev) < 0) + dev = NULL; break; default: dev = NULL; } - if (!dev || qdev_init(&dev->qdev) < 0) - return NULL; return dev; }