Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
docs/formatdomain.html.in | 20 ++++++++++++++++++++
docs/schemas/domaincommon.rng | 3 +++
src/conf/domain_conf.c | 10 ++++++++++
src/util/virstoragefile.c | 5 +++++
src/util/virstoragefile.h | 2 ++
5 files changed, 40 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index b63467bd91..a7fe8b5824 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2733,6 +2733,17 @@
</source>
<target dev='sdb' bus='scsi'/>
</disk>
+ </disk>
+ <disk type='network' device='lun'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='iscsi'
name='iqn.2013-07.com.example:iscsi-nopool/0'>
+ <host name='example.com' port='3260'/>
+ <initiator>
+ <iqn name='iqn.2013-07.com.example:client'/>
+ </initiator>
+ </source>
+ <target dev='sdb' bus='scsi'/>
+ </disk>
<disk type='volume' device='disk'>
<driver name='qemu' type='raw'/>
<source pool='iscsi-pool' volume='unit:0:0:1'
mode='host'/>
@@ -3090,6 +3101,15 @@
It's recommended to allow libvirt manage the persistent
reservations.
</dd>
+ <dt><code>initiator</code></dt>
+ <dd><span class="since">Since libvirt 4.7.0</span>,
the
+ <code>initiator</code> element is supported for a disk
+ <code>type</code> "network" that is using a
<code>source</code>
+ element with the <code>protocol</code> attribute
"iscsi".
+ If present, the <code>initiator</code> element provides the
+ initiator IQN needed to access the source via mandatory
+ attribute <code>name</code>.
+ </dd>
</dl>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ac04af51a1..1a786968cc 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1699,6 +1699,9 @@
<optional>
<ref name="encryption"/>
</optional>
+ <optional>
+ <ref name="initiatorinfo"/>
+ </optional>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d1504610a1..14112429fe 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8826,6 +8826,8 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
virStorageSourceNetworkAssignDefaultPorts(src);
+ virStorageSourceInitiatorParseXML(ctxt, &src->initiator);
+
ret = 0;
cleanup:
@@ -23541,6 +23543,8 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
virBufferEscapeString(childBuf, "<snapshot name='%s'/>\n",
src->snapshot);
virBufferEscapeString(childBuf, "<config file='%s'/>\n",
src->configFile);
+ virStorageSourceInitiatorFormatXML(&src->initiator, childBuf);
+
return 0;
}
@@ -30167,6 +30171,12 @@ virDomainDiskTranslateISCSIDircect(virDomainDiskDefPtr def,
if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0)
return -1;
+ if (!def->src->initiator.iqn && pooldef->source.initiator.iqn
&&
+ virStorageSourceInitiatorCopy(&def->src->initiator,
+ &pooldef->source.initiator) < 0) {
+ return -1;
+ }
+
return 0;
}
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index fb79ceddd0..6939d0d6c9 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2272,6 +2272,9 @@ virStorageSourceCopy(const virStorageSource *src,
!(ret->pr = virStoragePRDefCopy(src->pr)))
goto error;
+ if (virStorageSourceInitiatorCopy(&ret->initiator, &src->initiator))
+ goto error;
+
if (backingChain && src->backingStore) {
if (!(ret->backingStore = virStorageSourceCopy(src->backingStore,
true)))
@@ -2503,6 +2506,8 @@ virStorageSourceClear(virStorageSourcePtr def)
VIR_FREE(def->tlsAlias);
VIR_FREE(def->tlsCertdir);
+ virStorageSourceInitiatorClear(&def->initiator);
+
memset(def, 0, sizeof(*def));
}
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index b6013431cc..3ff6c4f900 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -261,6 +261,8 @@ struct _virStorageSource {
bool encryptionInherited;
virStoragePRDefPtr pr;
+ virStorageSourceInitiatorDef initiator;
+
virObjectPtr privateData;
int format; /* virStorageFileFormat in domain backing chains, but
--
2.17.1