Skip to content

Commit 90df0f8

Browse files
committed
conf: Add support for initiator IQN setting for iSCSI hostdevs
We already allow controlling the initiator IQN for iSCSI based disks. Add the same for host devices. Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Ján Tomko <[email protected]>
1 parent fdc0d13 commit 90df0f8

File tree

7 files changed

+24
-1
lines changed

7 files changed

+24
-1
lines changed

docs/formatdomain.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3771,6 +3771,9 @@ or:
37713771
<auth username='myuser'>
37723772
<secret type='iscsi' usage='libvirtiscsi'/>
37733773
</auth>
3774+
<initiator>
3775+
<iqn name='iqn.2020-07.com.example:test'/>
3776+
</initiator>
37743777
</source>
37753778
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
37763779
</hostdev>
@@ -3910,6 +3913,10 @@ or:
39103913
same ``name`` attribute and optionally using the ``auth`` element to
39113914
provide the authentication credentials to the iSCSI server.
39123915

3916+
:since:`Since 6.7.0`, the optional ``initiator`` sub-element controls the
3917+
IQN of the initiator ran by the hypervisor via it's ``<iqn name='iqn...'``
3918+
subelement.
3919+
39133920
``scsi_host``
39143921
:since:`Since 2.5.0` , multiple LUNs behind a single SCSI HBA are
39153922
described by a ``protocol`` attribute set to "vhost" and a ``wwpn``

docs/schemas/domaincommon.rng

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5058,6 +5058,9 @@
50585058
<optional>
50595059
<ref name='diskAuth'/>
50605060
</optional>
5061+
<optional>
5062+
<ref name="initiatorinfo"/>
5063+
</optional>
50615064
</interleave>
50625065
</group>
50635066
</choice>

src/conf/domain_conf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8354,6 +8354,8 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
83548354
iscsisrc->src->auth = g_steal_pointer(&authdef);
83558355
}
83568356

8357+
virStorageSourceInitiatorParseXML(ctxt, &iscsisrc->src->initiator);
8358+
83578359
if (flags & VIR_DOMAIN_DEF_PARSE_STATUS &&
83588360
xmlopt && xmlopt->privateData.storageParse) {
83598361
if ((ctxt->node = virXPathNode("./privateData", ctxt)) &&
@@ -26164,6 +26166,9 @@ virDomainHostdevDefFormatSubsysSCSI(virBufferPtr buf,
2616426166

2616526167
if (iscsisrc->src->auth)
2616626168
virStorageAuthDefFormat(&sourceChildBuf, iscsisrc->src->auth);
26169+
26170+
virStorageSourceInitiatorFormatXML(&iscsisrc->src->initiator,
26171+
&sourceChildBuf);
2616726172
} else {
2616826173
virBufferAsprintf(&sourceChildBuf, "<adapter name='%s'/>\n",
2616926174
scsihostsrc->adapter);

tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
6060
keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
6161
-drive file.driver=iscsi,file.portal=example.org:3260,\
6262
file.target=iqn.1992-01.com.example:storage,file.lun=2,file.transport=tcp,\
63-
file.user=myname,file.password-secret=hostdev5-secret0,if=none,format=raw,\
63+
file.user=myname,file.password-secret=hostdev5-secret0,\
64+
file.initiator-name=iqn.2020-07.com.example:test,if=none,format=raw,\
6465
id=drive-hostdev5 \
6566
-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=3,lun=5,\
6667
drive=drive-hostdev5,id=hostdev5 \

tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
6767
-blockdev '{"driver":"iscsi","portal":"example.org:3260",\
6868
"target":"iqn.1992-01.com.example:storage","lun":2,"transport":"tcp",\
6969
"user":"myname","password-secret":"hostdev5-secret0",\
70+
"initiator-name":"iqn.2020-07.com.example:test",\
7071
"node-name":"libvirt-hostdev5-backend","read-only":false}' \
7172
-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=3,lun=5,\
7273
drive=libvirt-hostdev5-backend,id=hostdev5 \

tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
<auth username='myname'>
6868
<secret type='iscsi' usage='mycluster_myname'/>
6969
</auth>
70+
<initiator>
71+
<iqn name='iqn.2020-07.com.example:test'/>
72+
</initiator>
7073
</source>
7174
<address type='drive' controller='0' bus='0' target='3' unit='5'/>
7275
</hostdev>

tests/qemuxml2xmloutdata/hostdev-scsi-virtio-scsi.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
<auth username='myname'>
7575
<secret type='iscsi' usage='mycluster_myname'/>
7676
</auth>
77+
<initiator>
78+
<iqn name='iqn.2020-07.com.example:test'/>
79+
</initiator>
7780
</source>
7881
<address type='drive' controller='0' bus='0' target='3' unit='5'/>
7982
</hostdev>

0 commit comments

Comments
 (0)