Patchwork [06/16] virtio-scsi: Open and initialize /dev/vhost-scsi

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

Comments

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

Begin adding vhost support by opening /dev/vhost-scsi.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 hw/virtio-scsi.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
index ff5d351..5c74523 100644
--- a/hw/virtio-scsi.c
+++ b/hw/virtio-scsi.c
@@ -18,6 +18,7 @@ 
 #include "virtio-scsi.h"
 #include <hw/scsi.h>
 #include <hw/scsi-defs.h>
+#include "vhost.h"
 
 #define VIRTIO_SCSI_VQ_SIZE     128
 #define VIRTIO_SCSI_CDB_SIZE    32
@@ -137,6 +138,9 @@  typedef struct {
     uint32_t sense_size;
     uint32_t cdb_size;
     int resetting;
+    struct vhost_virtqueue vhost_vqs[1];
+    bool vhost_started;
+    VHostSCSI *vhost_scsi;
 } VirtIOSCSI;
 
 typedef struct VirtIOSCSIReq {
@@ -446,6 +450,11 @@  static void virtio_scsi_fail_cmd_req(VirtIOSCSIReq *req)
     virtio_scsi_complete_req(req);
 }
 
+static VirtIOSCSI *to_virtio_scsi(VirtIODevice *vdev)
+{
+    return (VirtIOSCSI *)vdev;
+}
+
 static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
 {
     VirtIOSCSI *s = (VirtIOSCSI *)vdev;
@@ -588,6 +597,8 @@  VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf)
 
     s->qdev = dev;
     s->conf = proxyconf;
+    s->vhost_started = false;
+    s->vhost_scsi = proxyconf->vhost_scsi;
 
     /* TODO set up vdev function pointers */
     s->vdev.get_config = virtio_scsi_get_config;
@@ -617,5 +628,6 @@  void virtio_scsi_exit(VirtIODevice *vdev)
 {
     VirtIOSCSI *s = (VirtIOSCSI *)vdev;
     unregister_savevm(s->qdev, "virtio-scsi", s);
+    vhost_dev_cleanup(&s->vhost_scsi);
     virtio_cleanup(vdev);
 }