Blame 0211-iSCSI-We-need-to-support-SG_IO-also-from-iscsi_ioctl.patch

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