qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-scsi: forward scsibus for virtio-scsi-pci.
@ 2013-06-10  9:53 fred.konrad
  2013-06-10 11:58 ` Andreas Färber
  2013-06-10 17:00 ` Michael S. Tsirkin
  0 siblings, 2 replies; 8+ messages in thread
From: fred.konrad @ 2013-06-10  9:53 UTC (permalink / raw)
  To: aliguori, qemu-devel, qemu-stable
  Cc: aik, pbonzini, mst, mark.burton, fred.konrad

From: KONRAD Frederic <fred.konrad@greensocs.com>

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.

Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 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.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-11  7:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-10  9:53 [Qemu-devel] [PATCH] virtio-scsi: forward scsibus for virtio-scsi-pci fred.konrad
2013-06-10 11:58 ` Andreas Färber
2013-06-10 12:06   ` Frederic Konrad
2013-06-10 17:00 ` Michael S. Tsirkin
2013-06-11  6:43   ` Frederic Konrad
2013-06-11  7:21     ` Michael S. Tsirkin
2013-06-11  7:32       ` Frederic Konrad
2013-06-11  7:49         ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).