conf: introduce initiator IQN support for domain disks

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2018-08-07 13:32:56 +02:00
parent be16f170e7
commit 9ea3fdc6e9
5 changed files with 40 additions and 0 deletions

View File

@ -2733,6 +2733,17 @@
&lt;/source&gt;
&lt;target dev='sdb' bus='scsi'/&gt;
&lt;/disk&gt;
&lt;/disk&gt;
&lt;disk type='network' device='lun'&gt;
&lt;driver name='qemu' type='raw'/&gt;
&lt;source protocol='iscsi' name='iqn.2013-07.com.example:iscsi-nopool/0'&gt;
&lt;host name='example.com' port='3260'/&gt;
&lt;initiator&gt;
&lt;iqn name='iqn.2013-07.com.example:client'/&gt;
&lt;/initiator&gt;
&lt;/source&gt;
&lt;target dev='sdb' bus='scsi'/&gt;
&lt;/disk&gt;
&lt;disk type='volume' device='disk'&gt;
&lt;driver name='qemu' type='raw'/&gt;
&lt;source pool='iscsi-pool' volume='unit:0:0:1' mode='host'/&gt;
@ -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>

View File

@ -1699,6 +1699,9 @@
<optional>
<ref name="encryption"/>
</optional>
<optional>
<ref name="initiatorinfo"/>
</optional>
</element>
</define>

View File

@ -8853,6 +8853,8 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
virStorageSourceNetworkAssignDefaultPorts(src);
virStorageSourceInitiatorParseXML(ctxt, &src->initiator);
ret = 0;
cleanup:
@ -23568,6 +23570,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;
}
@ -30194,6 +30198,12 @@ virDomainDiskTranslateISCSIDirect(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;
}

View File

@ -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));
}

View File

@ -261,6 +261,8 @@ struct _virStorageSource {
bool encryptionInherited;
virStoragePRDefPtr pr;
virStorageSourceInitiatorDef initiator;
virObjectPtr privateData;
int format; /* virStorageFileFormat in domain backing chains, but