diff mbox

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

Message ID 1334803149-27379-14-git-send-email-zwu.kernel@gmail.com
State New
Headers show

Commit Message

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

Current we get -EINVAL, need to debug this.

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

Comments

Stefan Hajnoczi April 19, 2012, 11:03 a.m. UTC | #1
On Thu, Apr 19, 2012 at 10:39:06AM +0800, zwu.kernel@gmail.com wrote:
> From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

WIP == Work in progress

Unfinished patches like this should be resolved before sending a series
out.  Even for RFC patches I wouldn't leave this in because it adds too
much noise to qemu-devel and people will not want to review untidy code.

The endpoint setting should work now so the -EINVAL issue is probably
gone and the commit description can be fixed?

Stefan
Zhiyong Wu April 19, 2012, 11:28 a.m. UTC | #2
On Thu, Apr 19, 2012 at 7:03 PM, Stefan Hajnoczi
<stefanha@linux.vnet.ibm.com> wrote:
> On Thu, Apr 19, 2012 at 10:39:06AM +0800, zwu.kernel@gmail.com wrote:
>> From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
>
> WIP == Work in progress
>
> Unfinished patches like this should be resolved before sending a series
> out.  Even for RFC patches I wouldn't leave this in because it adds too
> much noise to qemu-devel and people will not want to review untidy code.
>
> The endpoint setting should work now so the -EINVAL issue is probably
> gone and the commit description can be fixed?
Yeah, OK.
>
> Stefan
>
diff mbox

Patch

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 */