qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 13/16] virtio-scsi: WIP VHOST_SCSI_SET_ENDPOINT call


From: zwu . kernel
Subject: [Qemu-devel] [PATCH 13/16] virtio-scsi: WIP VHOST_SCSI_SET_ENDPOINT call
Date: Thu, 19 Apr 2012 10:39:06 +0800

From: Stefan Hajnoczi <address@hidden>

Current we get -EINVAL, need to debug this.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Zhi Yong Wu <address@hidden>
---
 hw/vhost-scsi.c  |   19 ++++++++++++++++++-
 hw/virtio-scsi.h |   11 +----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/hw/vhost-scsi.c b/hw/vhost-scsi.c
index 6e3645f..82e0a68 100644
--- a/hw/vhost-scsi.c
+++ b/hw/vhost-scsi.c
@@ -11,6 +11,7 @@
  *
  */
 
+#include <sys/ioctl.h>
 #include "config.h"
 #include "qemu-queue.h"
 #include "vhost-scsi.h"
@@ -48,6 +49,14 @@ const char *vhost_scsi_get_id(VHostSCSI *vs)
 int vhost_scsi_start(VHostSCSI *vs, VirtIODevice *vdev)
 {
     int ret;
+    /* TODO #include <linux/vhost.h> properly */
+    struct vhost_vring_target {
+        unsigned char vhost_wwpn[224];
+        unsigned short vhost_tpgt;
+    } backend;
+#define VHOST_VIRTIO 0xAF
+#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct 
vhost_vring_target)
+#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct 
vhost_vring_target)
 
     if (!vhost_dev_query(&vs->dev, vdev)) {
         return -ENOTSUP;
@@ -60,7 +69,15 @@ int vhost_scsi_start(VHostSCSI *vs, VirtIODevice *vdev)
         return ret;
     }
 
-    /* TODO set wwpn and tpgt */
+    pstrcpy((char *)backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->wwpn);
+    backend.vhost_tpgt = vs->tpgt;
+    ret = ioctl(vs->dev.control, VHOST_SCSI_SET_ENDPOINT, &backend);
+    if (ret < 0) {
+        ret = -errno;
+        vhost_dev_stop(&vs->dev, vdev);
+        return ret;
+    }
+
     fprintf(stderr, "vhost_scsi_start\n");
     return 0;
 }
diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h
index 5f5f8c3..74e9422 100644
--- a/hw/virtio-scsi.h
+++ b/hw/virtio-scsi.h
@@ -22,6 +22,7 @@
 #define VIRTIO_ID_SCSI  8
 
 struct VirtIOSCSIConf {
+    VHostSCSI *vhost_scsi;
     uint32_t num_queues;
     uint32_t max_sectors;
     uint32_t cmd_per_lun;
@@ -33,14 +34,4 @@ struct VirtIOSCSIConf {
     DEFINE_PROP_UINT32("max_sectors", _state, _conf_field.max_sectors, 
0xFFFF), \
     DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128)
 
-/* For VHOST_SCSI_SET_ENDPOINT/VHOST_SCSI_CLEAR_ENDPOINT ioctl */
-struct vhost_vring_target {
-    unsigned char vhost_wwpn[224];
-    unsigned short vhost_tpgt;
-};
-
-typedef struct {
-    VHostSCSI *vhost_scsi;
-} VirtIOSCSIConf;
-
 #endif /* _QEMU_VIRTIO_SCSI_H */
-- 
1.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]