Patchwork [12/16] virtio-scsi: use the vhost-scsi host device

login
register
mail settings
Submitter Zhiyong Wu
Date April 19, 2012, 2:39 a.m.
Message ID <1334803149-27379-13-git-send-email-zwu.kernel@gmail.com>
Download mbox | patch
Permalink /patch/153639/
State New
Headers show

Comments

Zhiyong Wu - April 19, 2012, 2:39 a.m.
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

The vhost-scsi code was originally part of the virtio-scsi emulation.
This code has since been factored out and should be used instead.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 hw/virtio-pci.c  |    2 ++
 hw/virtio-scsi.c |   10 +++-------
 hw/virtio-scsi.h |    4 +---
 3 files changed, 6 insertions(+), 10 deletions(-)

Patch

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 025a518..107cc2d 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -984,6 +984,8 @@  static int virtio_scsi_exit_pci(PCIDevice *pci_dev)
 }
 
 static Property virtio_scsi_properties[] = {
+    DEFINE_PROP_VHOST_SCSI("vhost-scsi", VirtIOPCIProxy,
+                            scsi.vhost_scsi),
     DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
     DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOPCIProxy, host_features, scsi),
     DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
index 85170d3..e38cdd0 100644
--- a/hw/virtio-scsi.c
+++ b/hw/virtio-scsi.c
@@ -15,6 +15,7 @@ 
 
 #include "qemu-common.h"
 #include "qemu-error.h"
+#include "vhost-scsi.h"
 #include "virtio-scsi.h"
 #include <hw/scsi.h>
 #include <hw/scsi-defs.h>
@@ -602,11 +603,7 @@  static void virtio_scsi_set_status(VirtIODevice *vdev, uint8_t val)
     if (start) {
         int ret;
 
-        if (!vhost_dev_query(&s->vhost_scsi, vdev)) {
-            return;
-        }
-
-        ret = virtio_scsi_vhost_start(s);
+        ret = vhost_scsi_start(s->vhost_scsi, vdev);
         if (ret < 0) {
             error_report("virtio-scsi: unable to start vhost: %s\n",
                          strerror(-ret));
@@ -615,7 +612,7 @@  static void virtio_scsi_set_status(VirtIODevice *vdev, uint8_t val)
             exit(1);
         }
     } else {
-        virtio_scsi_vhost_stop(s);
+        vhost_scsi_stop(s->vhost_scsi, vdev);
     }
 
     s->vhost_started = start;
@@ -670,6 +667,5 @@  void virtio_scsi_exit(VirtIODevice *vdev)
     /* This will stop vhost backend if appropriate. */
     virtio_scsi_set_status(vdev, 0);
 
-    vhost_dev_cleanup(&s->vhost_scsi);
     virtio_cleanup(vdev);
 }
diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h
index f66d12c..5f5f8c3 100644
--- a/hw/virtio-scsi.h
+++ b/hw/virtio-scsi.h
@@ -40,9 +40,7 @@  struct vhost_vring_target {
 };
 
 typedef struct {
-    /* The tcm_vhost wwpn and tpgt */
-    char *wwpn;
-    uint16_t tpgt;
+    VHostSCSI *vhost_scsi;
 } VirtIOSCSIConf;
 
 #endif /* _QEMU_VIRTIO_SCSI_H */