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
---
docs/formatdomain.html.in | 7 ++-
docs/schemas/domaincommon.rng | 19 +++
src/conf/domain_conf.c | 21 +
.../qemuxml2argvdata/disk-backing-chains-index.xml | 12 ++--
.../disk-backing-chains-index-active.xml| 12 ++--
5 files changed, 54 insertions(+), 17 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 34664f7903..231e74e6b8 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2962,6 +2962,11 @@
is only valid when the specified storage volume is of 'file' or
'block' type).
+The source element may also have the index
+attribute with same semantics the
+index attribute of backingStore
+
+
The source element may contain the following sub elements:
@@ -3170,7 +3175,7 @@
by the backing store, see disk type attribute above for more
details and possible values.
- index
+ index
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
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 1a786968cc..e98f71536f 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1528,6 +1528,14 @@
+
+
+
+
+
+
+
+
@@ -1551,6 +1559,7 @@
+
@@ -1575,6 +1584,7 @@
+
@@ -1600,6 +1610,7 @@
+
@@ -1653,6 +1664,7 @@
rbd
+
@@ -1692,6 +1704,7 @@
iscsi
+
@@ -1714,6 +1727,7 @@
+
@@ -1732,6 +1746,7 @@
+
@@ -1752,6 +1767,7 @@
+
@@ -1765,6 +1781,7 @@
gluster
+
@@ -1782,6 +1799,7 @@
+
@@ -1826,6 +1844,7 @@
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c10e0a9eca..72602fb48c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9805,6 +9805,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
startupPolicy = virXMLPropString(cur, "startupPolicy");
+if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
+(tmp = virXMLPropString(cur, "index")) &&
+virStrToLong_uip(tmp, NULL, 10, >src->id) < 0) {
+virReportError(VIR_ERR_XML_ERROR, _("invalid disk index
'%s'"), tmp);
+goto error;
+}
+VIR_FREE(tmp);
} else if (!target &&
virXMLNodeNameEqual(cur, "target")) {
target = virXMLPropString(cur, "dev");
@@ -23776,6 +23783,7 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
int policy,
unsigned int flags,
bool skipSeclabels,
+ bool attrIndex,
virDomainXMLOptionPtr xmlopt)
{
virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
@@ -23792,6 +23800,9 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
virBufferEscapeString(, " startupPolicy='%s'",
virDomainStartupPolicyTypeToString(policy));
+if (attrIndex && src->id != 0)
+virBufferAsprintf(, " index='%u'", src->id);
+
if (virDomainDiskSourceFormatPrivateData(, src, flags, xmlopt) <
0)
goto cleanup;
@@ -23814,7 +23825,8 @@ virDomainDiskSourceFormat(virBufferPtr buf,
unsigned int flags,
virDomainXMLOptionPtr xmlopt)
{
-return virDomainDiskSourceFormatInternal(buf, src, policy, flags, false,
xmlopt);
+return virDomainDiskSourceFormatInternal(buf, src, policy, flags, false,
+ false, xmlopt);
}
@@ -23856,7 +23868,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
virBufferAsprintf(buf, "\n", format);
/*