[PATCH] add support of iSER transport type in qemu with libiscsi

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: zhangshengyu <zhangshengyu@xxxxxxxxxxxxxx>

---
 src/conf/domain_conf.c                             | 13 ++++++++
 src/qemu/qemu_block.c                              | 17 +++++++++-
 src/util/virstoragefile.c                          |  3 +-
 src/util/virstoragefile.h                          |  1 +
 tests/qemuxml2argvdata/disk-drive-network-iser.xml | 37 ++++++++++++++++++++++
 5 files changed, 69 insertions(+), 2 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/disk-drive-network-iser.xml

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 66e21c4bd..bf20cfd0c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7201,6 +7201,9 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
     iscsisrc->src->type = VIR_STORAGE_TYPE_NETWORK;
     iscsisrc->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
 
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("virDomainHostdevSubsysSCSIiSCSIDefParseXML"));
+
     if (!(iscsisrc->src->path = virXMLPropString(sourcenode, "name"))) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("missing iSCSI hostdev source path name"));
@@ -8416,6 +8419,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
                                 unsigned int flags)
 {
     char *protocol = NULL;
+    char *transport = NULL;
     char *haveTLS = NULL;
     char *tlsCfg = NULL;
     int tlsCfgVal;
@@ -8427,6 +8431,10 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
         goto cleanup;
     }
 
+    if (!(transport = virXMLPropString(node, "transport"))) {
+        VIR_WARN("missing network source transport type");
+    }
+                       
     if ((src->protocol = virStorageNetProtocolTypeFromString(protocol)) <= 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("unknown protocol type '%s'"), protocol);
@@ -8495,6 +8503,9 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
     if (virDomainStorageNetworkParseHosts(node, &src->hosts, &src->nhosts) < 0)
         goto cleanup;
 
+    if(src->hosts)
+        src->hosts->transport = virStorageNetHostTransportTypeFromString(transport);
+
     virStorageSourceNetworkAssignDefaultPorts(src);
 
     ret = 0;
@@ -22326,6 +22337,8 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
 
     VIR_FREE(path);
 
+    virBufferEscapeString(attrBuf, " transport='%s'", "iser");
+
     if (src->haveTLS != VIR_TRISTATE_BOOL_ABSENT &&
         !(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
           src->tlsFromConfig))
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 585f0255e..dcd7c6a5e 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -506,6 +506,20 @@ qemuBlockStorageSourceBuildJSONSocketAddress(virStorageNetHostDefPtr host,
             goto cleanup;
         break;
 
+    case VIR_STORAGE_NET_HOST_TRANS_ISER:
+        transport = "iser";
+        if (virAsprintf(&port, "%u", host->port) < 0)
+            goto cleanup;
+
+        if (virJSONValueObjectCreate(&server,
+                                     "s:type", transport,
+                                     "s:host", host->name,
+                                     "s:port", port,
+                                     NULL) < 0)
+            goto cleanup;
+
+
+        break;
     case VIR_STORAGE_NET_HOST_TRANS_UNIX:
         if (virJSONValueObjectCreate(&server,
                                      "s:type", "unix",
@@ -831,7 +845,8 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src)
                                           "s:portal", portal,
                                           "s:target", target,
                                           "u:lun", lun,
-                                          "s:transport", "tcp",
+                                          "s:transport", 
+                                          virStorageNetHostTransportTypeToString(src->hosts->transport),
                                           "S:user", username,
                                           "S:password-secret", objalias,
                                           NULL));
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 6594715e5..02d62a68e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -92,7 +92,8 @@ VIR_ENUM_IMPL(virStorageNetProtocol, VIR_STORAGE_NET_PROTOCOL_LAST,
 VIR_ENUM_IMPL(virStorageNetHostTransport, VIR_STORAGE_NET_HOST_TRANS_LAST,
               "tcp",
               "unix",
-              "rdma")
+              "rdma",
+              "iser")
 
 VIR_ENUM_IMPL(virStorageSourcePoolMode,
               VIR_STORAGE_SOURCE_POOL_MODE_LAST,
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 24382a0a6..4eb650186 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -147,6 +147,7 @@ typedef enum {
     VIR_STORAGE_NET_HOST_TRANS_TCP,
     VIR_STORAGE_NET_HOST_TRANS_UNIX,
     VIR_STORAGE_NET_HOST_TRANS_RDMA,
+    VIR_STORAGE_NET_HOST_TRANS_ISER,
 
     VIR_STORAGE_NET_HOST_TRANS_LAST
 } virStorageNetHostTransport;
diff --git a/tests/qemuxml2argvdata/disk-drive-network-iser.xml b/tests/qemuxml2argvdata/disk-drive-network-iser.xml
new file mode 100644
index 000000000..b3f4f9bfb
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-drive-network-iser.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>e301d9ab-f5ad-47bf-988c-9645577a1af4</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <disk type='network' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source protocol='iscsi' name='iqn.1992-01.com.example' transport='iser'>
+        <host name='example.org' port='6000'/>
+      </source>
+      <target dev='vda' bus='virtio'/>
+    </disk>
+    <disk type='network' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source protocol='iscsi' name='iqn.1992-01.com.example/1' transport='iser'>
+        <host name='example.org' port='6000'/>
+      </source>
+      <target dev='vdb' bus='virtio'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
-- 
2.13.6 (Apple Git-96)

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux