From 22b83a54f590e9993f8696d235957c91583d5f22 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 13 Mar 2019 17:42:37 +0100 Subject: [PATCH] conf: Add 'index' attribute for MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similarly to the disk source we need to keep the disk index (which is in the qemu driver used for identification of the source for block jobs) for the element so that when it's replaced as a disk source after pivoting all the allocated data is present. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 7 +++++-- tests/qemuxml2argvdata/disk-mirror.xml | 4 ++-- tests/qemuxml2xmloutdata/disk-mirror-active.xml | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c38102a510..bbde3788a6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9311,6 +9311,7 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, VIR_AUTOFREE(char *) mirrorType = NULL; VIR_AUTOFREE(char *) ready = NULL; VIR_AUTOFREE(char *) blockJob = NULL; + VIR_AUTOFREE(char *) index = NULL; ctxt->node = cur; @@ -9326,6 +9327,7 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, if ((mirrorType = virXMLPropString(cur, "type"))) { mirrorFormat = virXPathString("string(./format/@type)", ctxt); + index = virXPathString("string(./source/@index)", ctxt); } else { if (def->mirrorJob != VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -9336,7 +9338,8 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, mirrorFormat = virXMLPropString(cur, "format"); } - if (!(def->mirror = virDomainStorageSourceParseBase(mirrorType, mirrorFormat, NULL))) + if (!(def->mirror = virDomainStorageSourceParseBase(mirrorType, mirrorFormat, + index))) return -1; if (mirrorType) { @@ -24030,7 +24033,7 @@ virDomainDiskDefFormatMirror(virBufferPtr buf, virDomainDiskMirrorStateTypeToString(disk->mirrorState)); virBufferEscapeString(&childBuf, "\n", formatStr); - if (virDomainDiskSourceFormat(&childBuf, disk->mirror, 0, false, flags, xmlopt) < 0) + if (virDomainDiskSourceFormat(&childBuf, disk->mirror, 0, true, flags, xmlopt) < 0) return -1; if (virDomainDiskBackingStoreFormat(&childBuf, disk->mirror, xmlopt, flags) < 0) diff --git a/tests/qemuxml2argvdata/disk-mirror.xml b/tests/qemuxml2argvdata/disk-mirror.xml index c1e6e94e33..5a825c54ac 100644 --- a/tests/qemuxml2argvdata/disk-mirror.xml +++ b/tests/qemuxml2argvdata/disk-mirror.xml @@ -45,8 +45,8 @@ - - + + diff --git a/tests/qemuxml2xmloutdata/disk-mirror-active.xml b/tests/qemuxml2xmloutdata/disk-mirror-active.xml index 32ffc647be..bebdb849c2 100644 --- a/tests/qemuxml2xmloutdata/disk-mirror-active.xml +++ b/tests/qemuxml2xmloutdata/disk-mirror-active.xml @@ -51,8 +51,8 @@ - - + +