5544c1b
From 76fcbe46a52b467cd2cd96a671bfccd26871153e Mon Sep 17 00:00:00 2001
5544c1b
From: Ronnie Sahlberg <ronniesahlberg@gmail.com>
5544c1b
Date: Thu, 30 Aug 2012 17:28:40 -0700
5544c1b
Subject: [PATCH] iSCSI: We need to support SG_IO also from iscsi_ioctl()
5544c1b
5544c1b
We need to support SG_IO from the synchronous iscsi_ioctl() since
5544c1b
scsi-block uses this to do an INQ to the device to discover its properties
5544c1b
This patch makes scsi-block work with iscsi.
5544c1b
5544c1b
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
5544c1b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5544c1b
(cherry picked from commit f1a12821d7df2e4d21be4f2206f84b4640533e53)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 block/iscsi.c | 17 +++++++++++++++++
5544c1b
 1 file changed, 17 insertions(+)
5544c1b
5544c1b
diff --git a/block/iscsi.c b/block/iscsi.c
5544c1b
index 0b96165..ea16609 100644
5544c1b
--- a/block/iscsi.c
5544c1b
+++ b/block/iscsi.c
5544c1b
@@ -628,9 +628,17 @@ static BlockDriverAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
5544c1b
     return &acb->common;
5544c1b
 }
5544c1b
 
5544c1b
+
5544c1b
+static void ioctl_cb(void *opaque, int status)
5544c1b
+{
5544c1b
+    int *p_status = opaque;
5544c1b
+    *p_status = status;
5544c1b
+}
5544c1b
+
5544c1b
 static int iscsi_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
5544c1b
 {
5544c1b
     IscsiLun *iscsilun = bs->opaque;
5544c1b
+    int status;
5544c1b
 
5544c1b
     switch (req) {
5544c1b
     case SG_GET_VERSION_NUM:
5544c1b
@@ -639,6 +647,15 @@ static int iscsi_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
5544c1b
     case SG_GET_SCSI_ID:
5544c1b
         ((struct sg_scsi_id *)buf)->scsi_type = iscsilun->type;
5544c1b
         break;
5544c1b
+    case SG_IO:
5544c1b
+        status = -EINPROGRESS;
5544c1b
+        iscsi_aio_ioctl(bs, req, buf, ioctl_cb, &status);
5544c1b
+
5544c1b
+        while (status == -EINPROGRESS) {
5544c1b
+            qemu_aio_wait();
5544c1b
+        }
5544c1b
+
5544c1b
+        return 0;
5544c1b
     default:
5544c1b
         return -1;
5544c1b
     }
5544c1b
-- 
5544c1b
1.7.12.1
5544c1b