Patchwork [16/16] vhost-scsi: clear endpoint on stopped

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

Comments

Zhiyong Wu - April 19, 2012, 2:39 a.m.
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 hw/vhost-scsi.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/vhost-scsi.c b/hw/vhost-scsi.c
index 62f80bb..3e3378a 100644
--- a/hw/vhost-scsi.c
+++ b/hw/vhost-scsi.c
@@ -84,7 +84,16 @@  int vhost_scsi_start(VHostSCSI *vs, VirtIODevice *vdev)
 void vhost_scsi_stop(VHostSCSI *vs, VirtIODevice *vdev)
 {
     fprintf(stderr, "vhost_scsi_stop\n");
-    /* TODO clear wwpn and tpgt */
+
+    int ret;
+    struct vhost_vring_target backend;
+
+    pstrcpy((char *)backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->wwpn);
+    backend.vhost_tpgt = vs->tpgt;
+    ret = ioctl(vs->dev.control, VHOST_SCSI_CLEAR_ENDPOINT, &backend);
+    if (ret < 0) {
+        fprintf(stderr, "Failed to clear endpoint\n");
+    }
 
     vhost_dev_stop(&vs->dev, vdev);
 }