mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
conf: Allow formatting and parsing of 'index' for disk source image
Similarly to backing store indexes which will become stable eventually we need also to be able to format and store in the status XML for later use the index for the top level of the backing chain. Add XML formatter, parser, schema and docs. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
a6ea791e25
commit
9a28d3fd92
@ -3020,6 +3020,11 @@
|
|||||||
is only valid when the specified storage volume is of 'file' or
|
is only valid when the specified storage volume is of 'file' or
|
||||||
'block' type).
|
'block' type).
|
||||||
<p>
|
<p>
|
||||||
|
The <code>source</code> element may also have the <code>index</code>
|
||||||
|
attribute with same semantics the <a href='#elementsDiskBackingStoreIndex'>
|
||||||
|
<code>index</code></a> attribute of <code>backingStore</code>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
The <code>source</code> element may contain the following sub elements:
|
The <code>source</code> element may contain the following sub elements:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -3228,7 +3233,7 @@
|
|||||||
by the backing store, see disk type attribute above for more
|
by the backing store, see disk type attribute above for more
|
||||||
details and possible values.
|
details and possible values.
|
||||||
</dd>
|
</dd>
|
||||||
<dt><code>index</code></dt>
|
<dt><code><a id="elementsDiskBackingStoreIndex">index</a></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
This attribute is only valid in output (and ignored on input) and
|
This attribute is only valid in output (and ignored on input) and
|
||||||
it can be used to refer to a specific part of the disk chain when
|
it can be used to refer to a specific part of the disk chain when
|
||||||
|
@ -1545,6 +1545,14 @@
|
|||||||
</optional>
|
</optional>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
<define name="diskSourceCommon">
|
||||||
|
<optional>
|
||||||
|
<attribute name="index">
|
||||||
|
<ref name="positiveInteger"/>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
</define>
|
||||||
|
|
||||||
<define name="diskSource">
|
<define name="diskSource">
|
||||||
<choice>
|
<choice>
|
||||||
<ref name="diskSourceFile"/>
|
<ref name="diskSourceFile"/>
|
||||||
@ -1568,6 +1576,7 @@
|
|||||||
<ref name="absFilePath"/>
|
<ref name="absFilePath"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="storageStartupPolicy"/>
|
<ref name="storageStartupPolicy"/>
|
||||||
</optional>
|
</optional>
|
||||||
@ -1592,6 +1601,7 @@
|
|||||||
<ref name="absFilePath"/>
|
<ref name="absFilePath"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="storageStartupPolicy"/>
|
<ref name="storageStartupPolicy"/>
|
||||||
</optional>
|
</optional>
|
||||||
@ -1617,6 +1627,7 @@
|
|||||||
<attribute name="dir">
|
<attribute name="dir">
|
||||||
<ref name="absFilePath"/>
|
<ref name="absFilePath"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="storageStartupPolicy"/>
|
<ref name="storageStartupPolicy"/>
|
||||||
</optional>
|
</optional>
|
||||||
@ -1670,6 +1681,7 @@
|
|||||||
<attribute name="protocol">
|
<attribute name="protocol">
|
||||||
<value>rbd</value>
|
<value>rbd</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<optional>
|
<optional>
|
||||||
<attribute name="name"/>
|
<attribute name="name"/>
|
||||||
</optional>
|
</optional>
|
||||||
@ -1709,6 +1721,7 @@
|
|||||||
<value>iscsi</value>
|
<value>iscsi</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="name"/>
|
<attribute name="name"/>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<ref name="diskSourceNetworkHost"/>
|
<ref name="diskSourceNetworkHost"/>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="diskAuth"/>
|
<ref name="diskAuth"/>
|
||||||
@ -1731,6 +1744,7 @@
|
|||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="name"/>
|
<attribute name="name"/>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<ref name="diskSourceNetworkHost"/>
|
<ref name="diskSourceNetworkHost"/>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="encryption"/>
|
<ref name="encryption"/>
|
||||||
@ -1749,6 +1763,7 @@
|
|||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="name"/>
|
<attribute name="name"/>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<ref name="diskSourceNetworkHost"/>
|
<ref name="diskSourceNetworkHost"/>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="encryption"/>
|
<ref name="encryption"/>
|
||||||
@ -1769,6 +1784,7 @@
|
|||||||
<ref name="virYesNo"/>
|
<ref name="virYesNo"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<ref name="diskSourceNetworkHost"/>
|
<ref name="diskSourceNetworkHost"/>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="encryption"/>
|
<ref name="encryption"/>
|
||||||
@ -1782,6 +1798,7 @@
|
|||||||
<value>gluster</value>
|
<value>gluster</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="name"/>
|
<attribute name="name"/>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<oneOrMore>
|
<oneOrMore>
|
||||||
<ref name="diskSourceNetworkHost"/>
|
<ref name="diskSourceNetworkHost"/>
|
||||||
</oneOrMore>
|
</oneOrMore>
|
||||||
@ -1799,6 +1816,7 @@
|
|||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="name"/>
|
<attribute name="name"/>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<optional>
|
<optional>
|
||||||
<attribute name="tls">
|
<attribute name="tls">
|
||||||
<ref name="virYesNo"/>
|
<ref name="virYesNo"/>
|
||||||
@ -1843,6 +1861,7 @@
|
|||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<ref name="diskSourceCommon"/>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="storageStartupPolicy"/>
|
<ref name="storageStartupPolicy"/>
|
||||||
</optional>
|
</optional>
|
||||||
|
@ -9811,6 +9811,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
|
|
||||||
startupPolicy = virXMLPropString(cur, "startupPolicy");
|
startupPolicy = virXMLPropString(cur, "startupPolicy");
|
||||||
|
|
||||||
|
if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
|
||||||
|
(tmp = virXMLPropString(cur, "index")) &&
|
||||||
|
virStrToLong_uip(tmp, NULL, 10, &def->src->id) < 0) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, _("invalid disk index '%s'"), tmp);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
VIR_FREE(tmp);
|
||||||
} else if (!target &&
|
} else if (!target &&
|
||||||
virXMLNodeNameEqual(cur, "target")) {
|
virXMLNodeNameEqual(cur, "target")) {
|
||||||
target = virXMLPropString(cur, "dev");
|
target = virXMLPropString(cur, "dev");
|
||||||
@ -23979,6 +23986,7 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
|
|||||||
int policy,
|
int policy,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
bool skipSeclabels,
|
bool skipSeclabels,
|
||||||
|
bool attrIndex,
|
||||||
virDomainXMLOptionPtr xmlopt)
|
virDomainXMLOptionPtr xmlopt)
|
||||||
{
|
{
|
||||||
virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
|
virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
|
||||||
@ -23995,6 +24003,9 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
|
|||||||
virBufferEscapeString(&attrBuf, " startupPolicy='%s'",
|
virBufferEscapeString(&attrBuf, " startupPolicy='%s'",
|
||||||
virDomainStartupPolicyTypeToString(policy));
|
virDomainStartupPolicyTypeToString(policy));
|
||||||
|
|
||||||
|
if (attrIndex && src->id != 0)
|
||||||
|
virBufferAsprintf(&attrBuf, " index='%u'", src->id);
|
||||||
|
|
||||||
if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
|
if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -24017,7 +24028,8 @@ virDomainDiskSourceFormat(virBufferPtr buf,
|
|||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
virDomainXMLOptionPtr xmlopt)
|
virDomainXMLOptionPtr xmlopt)
|
||||||
{
|
{
|
||||||
return virDomainDiskSourceFormatInternal(buf, src, policy, flags, false, xmlopt);
|
return virDomainDiskSourceFormatInternal(buf, src, policy, flags, false,
|
||||||
|
false, xmlopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -24059,7 +24071,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
|
|||||||
|
|
||||||
virBufferAsprintf(buf, "<format type='%s'/>\n", format);
|
virBufferAsprintf(buf, "<format type='%s'/>\n", format);
|
||||||
/* We currently don't output seclabels for backing chain element */
|
/* We currently don't output seclabels for backing chain element */
|
||||||
if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, true, xmlopt) < 0 ||
|
if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, true,
|
||||||
|
false, xmlopt) < 0 ||
|
||||||
virDomainDiskBackingStoreFormat(buf, backingStore->backingStore,
|
virDomainDiskBackingStoreFormat(buf, backingStore->backingStore,
|
||||||
xmlopt, flags) < 0)
|
xmlopt, flags) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -24325,8 +24338,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
|
|||||||
if (def->src->auth && !def->src->authInherited)
|
if (def->src->auth && !def->src->authInherited)
|
||||||
virStorageAuthDefFormat(buf, def->src->auth);
|
virStorageAuthDefFormat(buf, def->src->auth);
|
||||||
|
|
||||||
if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy,
|
if (virDomainDiskSourceFormatInternal(buf, def->src, def->startupPolicy,
|
||||||
flags, xmlopt) < 0)
|
flags, false, true, xmlopt) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Don't format backingStore to inactive XMLs until the code for
|
/* Don't format backingStore to inactive XMLs until the code for
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<emulator>/usr/bin/qemu-system-i686</emulator>
|
<emulator>/usr/bin/qemu-system-i686</emulator>
|
||||||
<disk type='network' device='disk'>
|
<disk type='network' device='disk'>
|
||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source protocol='gluster' name='Volume2/Image'>
|
<source protocol='gluster' name='Volume2/Image' index='2'>
|
||||||
<host transport='unix' socket='/path/to/sock'/>
|
<host transport='unix' socket='/path/to/sock'/>
|
||||||
</source>
|
</source>
|
||||||
<backingStore type='file' index='1'>
|
<backingStore type='file' index='1'>
|
||||||
@ -27,7 +27,7 @@
|
|||||||
</disk>
|
</disk>
|
||||||
<disk type='network' device='disk'>
|
<disk type='network' device='disk'>
|
||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source protocol='nbd' name='bar'>
|
<source protocol='nbd' name='bar' index='9'>
|
||||||
<host transport='unix' socket='/var/run/nbdsock'/>
|
<host transport='unix' socket='/var/run/nbdsock'/>
|
||||||
</source>
|
</source>
|
||||||
<backingStore type='block' index='8'>
|
<backingStore type='block' index='8'>
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<disk type='network' device='disk'>
|
<disk type='network' device='disk'>
|
||||||
<driver name='qemu' type='raw'/>
|
<driver name='qemu' type='raw'/>
|
||||||
<backingStore/>
|
<backingStore/>
|
||||||
<source protocol='gluster' name='Volume1/Image'>
|
<source protocol='gluster' name='Volume1/Image' index='10'>
|
||||||
<host name='example.org' port='6000'/>
|
<host name='example.org' port='6000'/>
|
||||||
</source>
|
</source>
|
||||||
<target dev='vdc' bus='virtio'/>
|
<target dev='vdc' bus='virtio'/>
|
||||||
@ -71,7 +71,7 @@
|
|||||||
<auth username='myname'>
|
<auth username='myname'>
|
||||||
<secret type='ceph' usage='mycluster_myname'/>
|
<secret type='ceph' usage='mycluster_myname'/>
|
||||||
</auth>
|
</auth>
|
||||||
<source protocol='rbd' name='pool/image'>
|
<source protocol='rbd' name='pool/image' index='12'>
|
||||||
<host name='mon1.example.org' port='6321'/>
|
<host name='mon1.example.org' port='6321'/>
|
||||||
<host name='mon2.example.org' port='6322'/>
|
<host name='mon2.example.org' port='6322'/>
|
||||||
<host name='mon3.example.org' port='6322'/>
|
<host name='mon3.example.org' port='6322'/>
|
||||||
@ -85,12 +85,12 @@
|
|||||||
</disk>
|
</disk>
|
||||||
<disk type='block' device='disk'>
|
<disk type='block' device='disk'>
|
||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source dev='/dev/HostVG/QEMUGuest11'/>
|
<source dev='/dev/HostVG/QEMUGuest11' index='13'/>
|
||||||
<target dev='vde' bus='virtio'/>
|
<target dev='vde' bus='virtio'/>
|
||||||
</disk>
|
</disk>
|
||||||
<disk type='file' device='disk'>
|
<disk type='file' device='disk'>
|
||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source file='/var/lib/libvirt/images/rhel7.1484071880'/>
|
<source file='/var/lib/libvirt/images/rhel7.1484071880' index='25'/>
|
||||||
<backingStore type='file' index='24'>
|
<backingStore type='file' index='24'>
|
||||||
<format type='qcow2'/>
|
<format type='qcow2'/>
|
||||||
<source file='/var/lib/libvirt/images/rhel7.1484071877'/>
|
<source file='/var/lib/libvirt/images/rhel7.1484071877'/>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<emulator>/usr/bin/qemu-system-i686</emulator>
|
<emulator>/usr/bin/qemu-system-i686</emulator>
|
||||||
<disk type='network' device='disk'>
|
<disk type='network' device='disk'>
|
||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source protocol='gluster' name='Volume2/Image'>
|
<source protocol='gluster' name='Volume2/Image' index='2'>
|
||||||
<host transport='unix' socket='/path/to/sock'/>
|
<host transport='unix' socket='/path/to/sock'/>
|
||||||
</source>
|
</source>
|
||||||
<backingStore type='file' index='1'>
|
<backingStore type='file' index='1'>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
</disk>
|
</disk>
|
||||||
<disk type='network' device='disk'>
|
<disk type='network' device='disk'>
|
||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source protocol='nbd' name='bar'>
|
<source protocol='nbd' name='bar' index='9'>
|
||||||
<host transport='unix' socket='/var/run/nbdsock'/>
|
<host transport='unix' socket='/var/run/nbdsock'/>
|
||||||
</source>
|
</source>
|
||||||
<backingStore type='block' index='8'>
|
<backingStore type='block' index='8'>
|
||||||
@ -61,7 +61,7 @@
|
|||||||
</disk>
|
</disk>
|
||||||
<disk type='network' device='disk'>
|
<disk type='network' device='disk'>
|
||||||
<driver name='qemu' type='raw'/>
|
<driver name='qemu' type='raw'/>
|
||||||
<source protocol='gluster' name='Volume1/Image'>
|
<source protocol='gluster' name='Volume1/Image' index='10'>
|
||||||
<host name='example.org' port='6000'/>
|
<host name='example.org' port='6000'/>
|
||||||
</source>
|
</source>
|
||||||
<backingStore/>
|
<backingStore/>
|
||||||
@ -73,7 +73,7 @@
|
|||||||
<auth username='myname'>
|
<auth username='myname'>
|
||||||
<secret type='ceph' usage='mycluster_myname'/>
|
<secret type='ceph' usage='mycluster_myname'/>
|
||||||
</auth>
|
</auth>
|
||||||
<source protocol='rbd' name='pool/image'>
|
<source protocol='rbd' name='pool/image' index='12'>
|
||||||
<host name='mon1.example.org' port='6321'/>
|
<host name='mon1.example.org' port='6321'/>
|
||||||
<host name='mon2.example.org' port='6322'/>
|
<host name='mon2.example.org' port='6322'/>
|
||||||
<host name='mon3.example.org' port='6322'/>
|
<host name='mon3.example.org' port='6322'/>
|
||||||
@ -88,13 +88,13 @@
|
|||||||
</disk>
|
</disk>
|
||||||
<disk type='block' device='disk'>
|
<disk type='block' device='disk'>
|
||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source dev='/dev/HostVG/QEMUGuest11'/>
|
<source dev='/dev/HostVG/QEMUGuest11' index='13'/>
|
||||||
<target dev='vde' bus='virtio'/>
|
<target dev='vde' bus='virtio'/>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
|
||||||
</disk>
|
</disk>
|
||||||
<disk type='file' device='disk'>
|
<disk type='file' device='disk'>
|
||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source file='/var/lib/libvirt/images/rhel7.1484071880'/>
|
<source file='/var/lib/libvirt/images/rhel7.1484071880' index='25'/>
|
||||||
<backingStore type='file' index='24'>
|
<backingStore type='file' index='24'>
|
||||||
<format type='qcow2'/>
|
<format type='qcow2'/>
|
||||||
<source file='/var/lib/libvirt/images/rhel7.1484071877'/>
|
<source file='/var/lib/libvirt/images/rhel7.1484071877'/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user