[PATCH v2 3/6] qemu: Implement the iSCSI iSER

Han Han hhan at redhat.com
Fri May 15 03:46:02 UTC 2020


The iSCSI iSER transport is introdcued since QEMU 2.9. For blockdev json,
it will appear at 'transport' field:
'json:{...,{"driver": "iscsi","transport":"iser",...}}'

For legacy drive filename as iscsi uri, it will start with 'iser'
scheme:
iser://[[username][%<password>]@]<host>[:<port>]/<target-iqn-name>/<lun>

Signed-off-by: Han Han <hhan at redhat.com>
---
 src/qemu/qemu_block.c   | 11 +++++++++--
 src/qemu/qemu_command.c |  3 +++
 src/qemu/qemu_domain.c  |  9 +++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 6f9c7071..4261e110 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -421,7 +421,10 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src)
     if (src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP) {
         uri->port = src->hosts->port;
 
-        uri->scheme = g_strdup(virStorageNetProtocolTypeToString(src->protocol));
+        if (src->iscsiIser)
+            uri->scheme = g_strdup("iser");
+        else
+            uri->scheme = g_strdup(virStorageNetProtocolTypeToString(src->protocol));
     } else {
         uri->scheme = g_strdup_printf("%s+%s",
                                       virStorageNetProtocolTypeToString(src->protocol),
@@ -746,6 +749,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src,
     char *lunStr = NULL;
     char *username = NULL;
     char *objalias = NULL;
+    const char *transport = "tcp";
     g_autofree char *portal = NULL;
     unsigned int lun = 0;
     virJSONValuePtr ret = NULL;
@@ -761,6 +765,9 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src,
      * }
      */
 
+    if (src->iscsiIser)
+        transport = "iser";
+
     target = g_strdup(src->path);
 
     /* Separate the target and lun */
@@ -791,7 +798,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src,
                                           "s:portal", portal,
                                           "s:target", target,
                                           "u:lun", lun,
-                                          "s:transport", "tcp",
+                                          "s:transport", transport,
                                           "S:user", username,
                                           "S:password-secret", objalias,
                                           "S:initiator-name", src->initiator.iqn,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bfe70ed2..1d5a302a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5087,6 +5087,9 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
                 qemuDomainStorageSourcePrivatePtr srcPriv =
                     QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
 
+                if (qemuDomainValidateStorageSource(iscsisrc->src, qemuCaps, true) < 0)
+                    return -1;
+
                 if (qemuBuildDiskSecinfoCommandLine(cmd, srcPriv ?
                                                     srcPriv->secinfo :
                                                     NULL) < 0)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a1b250fd..41e97bf7 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5318,6 +5318,15 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
         return -1;
     }
 
+    if (qemuCaps) {
+        if (src->iscsiIser &&
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_ISCSI_ISER)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                _("iSCSI iSER is not supported with this QEMU binary"));
+                return -1;
+            }
+    }
+
     return 0;
 }
 
-- 
2.25.0




More information about the libvir-list mailing list