From nobody Mon Feb 9 07:38:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533651820860233.65894673164723; Tue, 7 Aug 2018 07:23:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D91283002891; Tue, 7 Aug 2018 14:23:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9363A3001A69; Tue, 7 Aug 2018 14:23:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4571314B0B; Tue, 7 Aug 2018 14:23:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w77EN5F1010264 for ; Tue, 7 Aug 2018 10:23:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id ACA5C2166BA2; Tue, 7 Aug 2018 14:23:05 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 488B62166BA0 for ; Tue, 7 Aug 2018 14:23:05 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 7 Aug 2018 16:22:14 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 23/55] conf: Allow formatting and parsing of 'index' for disk source image X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 07 Aug 2018 14:23:39 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 b63467bd91..f175d931ec 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2951,6 +2951,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 elem= ents:

@@ -3150,7 +3155,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 w= hen diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ac04af51a1..7c4e848685 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 + @@ -1711,6 +1724,7 @@ + @@ -1729,6 +1743,7 @@ + @@ -1749,6 +1764,7 @@ + @@ -1762,6 +1778,7 @@ gluster + @@ -1779,6 +1796,7 @@ + @@ -1823,6 +1841,7 @@ + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a9db7cd380..720b418920 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9677,6 +9677,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlop= t, startupPolicy =3D virXMLPropString(cur, "startupPolicy"); + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && + (tmp =3D 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 && virXMLNodeNameEqual(cur, "target")) { target =3D virXMLPropString(cur, "dev"); @@ -23681,6 +23688,7 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, int policy, unsigned int flags, bool skipSeclabels, + bool attrIndex, virDomainXMLOptionPtr xmlopt) { virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; @@ -23697,6 +23705,9 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", virDomainStartupPolicyTypeToString(policy)); + if (attrIndex && src->id !=3D 0) + virBufferAsprintf(&attrBuf, " index=3D'%u'", src->id); + if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt= ) < 0) goto cleanup; @@ -23719,7 +23730,8 @@ virDomainDiskSourceFormat(virBufferPtr buf, unsigned int flags, virDomainXMLOptionPtr xmlopt) { - return virDomainDiskSourceFormatInternal(buf, src, policy, flags, fals= e, xmlopt); + return virDomainDiskSourceFormatInternal(buf, src, policy, flags, fals= e, + false, xmlopt); } @@ -23761,7 +23773,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, virBufferAsprintf(buf, "\n", format); /* We currently don't output seclabels for backing chain element */ - if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, tru= e, xmlopt) < 0 || + if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, tru= e, + false, xmlopt) < 0 || virDomainDiskBackingStoreFormat(buf, backingStore->backingStore, xmlopt, flags) < 0) return -1; @@ -24027,8 +24040,8 @@ virDomainDiskDefFormat(virBufferPtr buf, if (def->src->auth && !def->src->authInherited) virStorageAuthDefFormat(buf, def->src->auth); - if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy, - flags, xmlopt) < 0) + if (virDomainDiskSourceFormatInternal(buf, def->src, def->startupPolic= y, + flags, false, true, xmlopt) < 0) return -1; /* Don't format backingStore to inactive XMLs until the code for diff --git a/tests/qemuxml2argvdata/disk-backing-chains-index.xml b/tests/q= emuxml2argvdata/disk-backing-chains-index.xml index 95b8a64cf8..5e0a03fbc4 100644 --- a/tests/qemuxml2argvdata/disk-backing-chains-index.xml +++ b/tests/qemuxml2argvdata/disk-backing-chains-index.xml @@ -16,7 +16,7 @@ /usr/bin/qemu-system-i686 - + @@ -27,7 +27,7 @@ - + @@ -61,7 +61,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -85,12 +85,12 @@ - + - + diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml = b/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml index 724afa4e83..2b5bc9e1b4 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml @@ -16,7 +16,7 @@ /usr/bin/qemu-system-i686 - + @@ -28,7 +28,7 @@ - + @@ -61,7 +61,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -88,13 +88,13 @@ - +
- + --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list