[PATCH 9/9] qemu: add support for domain disk initiator IQN

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/qemu/qemu_block.c                                 |  2 ++
 src/qemu/qemu_domain.c                                |  9 +++++++++
 tests/qemuxml2argvdata/disk-network-iscsi-modern.args |  8 +++++++-
 tests/qemuxml2argvdata/disk-network-iscsi-modern.xml  | 10 ++++++++++
 4 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 66e6301210..be120b30f0 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -819,6 +819,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src)
      *   lun:1,
      *   user:"username",
      *   password-secret:"secret-alias",
+     *   initiator-name:"iqn.2017-04.com.example:client"
      * }
      */
 
@@ -860,6 +861,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src)
                                           "s:transport", "tcp",
                                           "S:user", username,
                                           "S:password-secret", objalias,
+                                          "S:initiator-name", src->initiator.iqn,
                                           NULL));
         goto cleanup;
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 6b50e0c484..e8960105c3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4682,6 +4682,15 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
         return -1;
     }
 
+    /* Use QEMU_CAPS_ISCSI_PASSWORD_SECRET as witness that iscsi 'initiator-name'
+     * option is available, it was introduced at the same time. */
+    if (src->initiator.iqn &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("iSCSI initiator IQN not supported with this QEMU binary"));
+        return -1;
+    }
+
     return 0;
 }
 
diff --git a/tests/qemuxml2argvdata/disk-network-iscsi-modern.args b/tests/qemuxml2argvdata/disk-network-iscsi-modern.args
index 0a3e0bdb8b..a06b63a940 100644
--- a/tests/qemuxml2argvdata/disk-network-iscsi-modern.args
+++ b/tests/qemuxml2argvdata/disk-network-iscsi-modern.args
@@ -49,4 +49,10 @@ id=virtio-disk3 \
 file.target=iqn.1992-01.com.example,file.lun=0,file.transport=tcp,format=raw,\
 if=none,id=drive-scsi0-0-0-0 \
 -device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
-drive=drive-scsi0-0-0-0,id=scsi0-0-0-0
+drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
+-drive file.driver=iscsi,file.portal=example.org:3260,\
+file.target=iqn.1992-01.com.example:server,file.lun=0,file.transport=tcp,\
+file.initiator-name=iqn.1992-01.com.example:client,format=raw,if=none,\
+id=drive-scsi0-0-0-1 \
+-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=1,\
+drive=drive-scsi0-0-0-1,id=scsi0-0-0-1
diff --git a/tests/qemuxml2argvdata/disk-network-iscsi-modern.xml b/tests/qemuxml2argvdata/disk-network-iscsi-modern.xml
index fa2a889b54..d1be9c4e7d 100644
--- a/tests/qemuxml2argvdata/disk-network-iscsi-modern.xml
+++ b/tests/qemuxml2argvdata/disk-network-iscsi-modern.xml
@@ -55,6 +55,16 @@
       </source>
       <target dev='sda' bus='scsi'/>
     </disk>
+    <disk type='network' device='lun'>
+      <driver name='qemu' type='raw'/>
+      <source protocol='iscsi' name='iqn.1992-01.com.example:server/0'>
+        <host name='example.org' port='3260'/>
+        <initiator>
+          <iqn name='iqn.1992-01.com.example:client'/>
+        </initiator>
+      </source>
+      <target dev='sdb' bus='scsi'/>
+    </disk>
     <controller type='usb' index='0'/>
     <controller type='pci' index='0' model='pci-root'/>
     <controller type='scsi' index='0' model='virtio-scsi'/>
-- 
2.17.1

--
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