[PATCH 11/11] conf: Add support for initiator IQN setting for iSCSI hostdevs

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

 



We already allow controlling the initiator IQN for iSCSI based disks.
Add the same for host devices.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 docs/formatdomain-devices-hostdev.rst.in                   | 7 +++++++
 docs/schemas/domaincommon.rng                              | 3 +++
 src/conf/domain_conf.c                                     | 5 +++++
 .../hostdev-scsi-virtio-scsi.x86_64-4.1.0.args             | 3 ++-
 .../hostdev-scsi-virtio-scsi.x86_64-latest.args            | 1 +
 tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml        | 3 +++
 tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml      | 3 +++
 7 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain-devices-hostdev.rst.in b/docs/formatdomain-devices-hostdev.rst.in
index 859c4b4ec5..1221627818 100644
--- a/docs/formatdomain-devices-hostdev.rst.in
+++ b/docs/formatdomain-devices-hostdev.rst.in
@@ -68,6 +68,9 @@ or:
      <hostdev mode='subsystem' type='scsi'>
        <source protocol='iscsi' name='iqn.2014-08.com.example:iscsi-nopool/1'>
          <host name='example.com' port='3260'/>
+         <initiator>
+           <iqn name='iqn.2020-07.com.example:test'/>
+         </initiator>
          <auth username='myuser'>
            <secret type='iscsi' usage='libvirtiscsi'/>
          </auth>
@@ -210,6 +213,10 @@ or:
       same ``name`` attribute and optionally using the ``auth`` element to
       provide the authentication credentials to the iSCSI server.

+      :since:`Since 6.6.0`, the optional ``initiator`` sub-element controls the
+      IQN of the initiator ran by the hypervisor via it's ``<iqn name='iqn...'``
+      subelement.
+
    ``scsi_host``
       :since:`Since 2.5.0` , multiple LUNs behind a single SCSI HBA are
       described by a ``protocol`` attribute set to "vhost" and a ``wwpn``
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index a810f569c6..815793138e 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5045,6 +5045,9 @@
             <optional>
               <ref name='diskAuth'/>
             </optional>
+            <optional>
+              <ref name="initiatorinfo"/>
+            </optional>
           </interleave>
         </group>
       </choice>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5988a13986..5c23a52031 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8349,6 +8349,8 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
         iscsisrc->src->auth = g_steal_pointer(&authdef);
     }

+    virStorageSourceInitiatorParseXML(ctxt, &iscsisrc->src->initiator);
+
     if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) &&
         xmlopt && xmlopt->privateData.storageParse) {
         if ((ctxt->node = virXPathNode("./privateData", ctxt)) &&
@@ -26128,6 +26130,9 @@ virDomainHostdevDefFormatSubsysSCSI(virBufferPtr buf,

         if (iscsisrc->src->auth)
             virStorageAuthDefFormat(&sourceChildBuf, iscsisrc->src->auth);
+
+        virStorageSourceInitiatorFormatXML(&iscsisrc->src->initiator,
+                                           &sourceChildBuf);
     } else {
         virBufferAsprintf(&sourceChildBuf, "<adapter name='%s'/>\n",
                           scsihostsrc->adapter);
diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args
index de4047000e..f2591d6956 100644
--- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args
+++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args
@@ -60,7 +60,8 @@ data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
 keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -drive file.driver=iscsi,file.portal=example.org:3260,\
 file.target=iqn.1992-01.com.example:storage,file.lun=2,file.transport=tcp,\
-file.user=myname,file.password-secret=hostdev5-secret0,if=none,format=raw,\
+file.user=myname,file.password-secret=hostdev5-secret0,\
+file.initiator-name=iqn.2020-07.com.example:test,if=none,format=raw,\
 id=drive-hostdev5 \
 -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=3,lun=5,\
 drive=drive-hostdev5,id=hostdev5 \
diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args
index 72980d58b8..f86cbd7314 100644
--- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args
@@ -67,6 +67,7 @@ keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -blockdev '{"driver":"iscsi","portal":"example.org:3260",\
 "target":"iqn.1992-01.com.example:storage","lun":2,"transport":"tcp",\
 "user":"myname","password-secret":"hostdev5-secret0",\
+"initiator-name":"iqn.2020-07.com.example:test",\
 "node-name":"libvirt-hostdev5-backend","read-only":false}' \
 -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=3,lun=5,\
 drive=libvirt-hostdev5-backend,id=hostdev5 \
diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml
index 775b678b36..f1caf80644 100644
--- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml
+++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml
@@ -67,6 +67,9 @@
         <auth username='myname'>
           <secret type='iscsi' usage='mycluster_myname'/>
         </auth>
+        <initiator>
+          <iqn name='iqn.2020-07.com.example:test'/>
+        </initiator>
       </source>
       <address type='drive' controller='0' bus='0' target='3' unit='5'/>
     </hostdev>
diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml b/tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml
index 9c823809ab..6c7e22d0c3 100644
--- a/tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml
+++ b/tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml
@@ -74,6 +74,9 @@
         <auth username='myname'>
           <secret type='iscsi' usage='mycluster_myname'/>
         </auth>
+        <initiator>
+          <iqn name='iqn.2020-07.com.example:test'/>
+        </initiator>
       </source>
       <address type='drive' controller='0' bus='0' target='3' unit='5'/>
     </hostdev>
-- 
2.26.2




[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