From nobody Mon Feb 9 05:00:29 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 1534176107751191.57366690535014; Mon, 13 Aug 2018 09:01:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B442307CF30; Mon, 13 Aug 2018 16:01:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F26260BE7; Mon, 13 Aug 2018 16:01:44 +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 99E8318037FC; Mon, 13 Aug 2018 16:01:43 +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 w7DG0whJ001433 for ; Mon, 13 Aug 2018 12:00:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C77E2166BA5; Mon, 13 Aug 2018 16:00:58 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A8582166BA0 for ; Mon, 13 Aug 2018 16:00:57 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 13 Aug 2018 18:00:00 +0200 Message-Id: <1ef0695a7d3ec153707a0bae2b7629c7c99aeaed.1534173735.git.pkrempa@redhat.com> 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] [PATCHv2 26/62] 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 13 Aug 2018 16:01:46 +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 Reviewed-by: J=EF=BF=BDn Tomko --- 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 elem= ents:

@@ -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 w= hen 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 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"); @@ -23776,6 +23783,7 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, int policy, unsigned int flags, bool skipSeclabels, + bool attrIndex, virDomainXMLOptionPtr xmlopt) { virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; @@ -23792,6 +23800,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; @@ -23814,7 +23825,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); } @@ -23856,7 +23868,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; @@ -24122,8 +24135,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