From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9GGF-0004Qf-4N for qemu-devel@nongnu.org; Tue, 13 Aug 2013 11:11:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9GGA-0003hm-R1 for qemu-devel@nongnu.org; Tue, 13 Aug 2013 11:11:51 -0400 Sender: fluxion From: Michael Roth Date: Tue, 13 Aug 2013 10:10:29 -0500 Message-Id: <1376406680-16302-6-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1376406680-16302-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1376406680-16302-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 05/56] virtio-scsi: forward scsibus for virtio-scsi-pci. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, qemu-stable@nongnu.org From: KONRAD Frederic This fix a bug with scsi hotplug on virtio-scsi-pci: As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus. Cc: qemu-stable@nongnu.org Reported-by: Alexey Kardashevskiy Reviewed-by: Andreas Färber Signed-off-by: KONRAD Frederic Acked-by: Michael S. Tsirkin Signed-off-by: Michael Roth --- hw/pci/pci-hotplug.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index 12287d1..c708752 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -30,6 +30,8 @@ #include "monitor/monitor.h" #include "hw/scsi/scsi.h" #include "hw/virtio/virtio-blk.h" +#include "hw/virtio/virtio-scsi.h" +#include "hw/virtio/virtio-pci.h" #include "qemu/config-file.h" #include "sysemu/blockdev.h" #include "qapi/error.h" @@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter, { SCSIBus *scsibus; SCSIDevice *scsidev; + VirtIOPCIProxy *virtio_proxy; scsibus = (SCSIBus *) object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)), TYPE_SCSI_BUS); if (!scsibus) { - error_report("Device is not a SCSI adapter"); - return -1; + /* + * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add + * to the virtio-scsi-device. + */ + if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) { + error_report("Device is not a SCSI adapter"); + return -1; + } + virtio_proxy = VIRTIO_PCI(adapter); + adapter = DEVICE(virtio_proxy->bus.vdev); + scsibus = (SCSIBus *) + object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)), + TYPE_SCSI_BUS); + assert(scsibus); } /* -- 1.7.9.5