conf: Add 'index' attribute for <disk><mirror><source>

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 <mirror> element so that when it's replaced as a disk source
after pivoting all the allocated data is present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-03-13 17:42:37 +01:00
parent 4e797f1af9
commit 22b83a54f5
3 changed files with 9 additions and 6 deletions

View File

@ -9311,6 +9311,7 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
VIR_AUTOFREE(char *) mirrorType = NULL; VIR_AUTOFREE(char *) mirrorType = NULL;
VIR_AUTOFREE(char *) ready = NULL; VIR_AUTOFREE(char *) ready = NULL;
VIR_AUTOFREE(char *) blockJob = NULL; VIR_AUTOFREE(char *) blockJob = NULL;
VIR_AUTOFREE(char *) index = NULL;
ctxt->node = cur; ctxt->node = cur;
@ -9326,6 +9327,7 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
if ((mirrorType = virXMLPropString(cur, "type"))) { if ((mirrorType = virXMLPropString(cur, "type"))) {
mirrorFormat = virXPathString("string(./format/@type)", ctxt); mirrorFormat = virXPathString("string(./format/@type)", ctxt);
index = virXPathString("string(./source/@index)", ctxt);
} else { } else {
if (def->mirrorJob != VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) { if (def->mirrorJob != VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
@ -9336,7 +9338,8 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
mirrorFormat = virXMLPropString(cur, "format"); mirrorFormat = virXMLPropString(cur, "format");
} }
if (!(def->mirror = virDomainStorageSourceParseBase(mirrorType, mirrorFormat, NULL))) if (!(def->mirror = virDomainStorageSourceParseBase(mirrorType, mirrorFormat,
index)))
return -1; return -1;
if (mirrorType) { if (mirrorType) {
@ -24030,7 +24033,7 @@ virDomainDiskDefFormatMirror(virBufferPtr buf,
virDomainDiskMirrorStateTypeToString(disk->mirrorState)); virDomainDiskMirrorStateTypeToString(disk->mirrorState));
virBufferEscapeString(&childBuf, "<format type='%s'/>\n", formatStr); virBufferEscapeString(&childBuf, "<format type='%s'/>\n", formatStr);
if (virDomainDiskSourceFormat(&childBuf, disk->mirror, 0, false, flags, xmlopt) < 0) if (virDomainDiskSourceFormat(&childBuf, disk->mirror, 0, true, flags, xmlopt) < 0)
return -1; return -1;
if (virDomainDiskBackingStoreFormat(&childBuf, disk->mirror, xmlopt, flags) < 0) if (virDomainDiskBackingStoreFormat(&childBuf, disk->mirror, xmlopt, flags) < 0)

View File

@ -45,8 +45,8 @@
<backingStore/> <backingStore/>
<mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'> <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'>
<format type='qcow2'/> <format type='qcow2'/>
<source file='/tmp/logcopy.img'/> <source file='/tmp/logcopy.img' index='1'/>
<backingStore type='block' index='1'> <backingStore type='block' index='2'>
<format type='raw'/> <format type='raw'/>
<source dev='/dev/HostVG/backing'/> <source dev='/dev/HostVG/backing'/>
<backingStore/> <backingStore/>

View File

@ -51,8 +51,8 @@
<backingStore/> <backingStore/>
<mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'> <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'>
<format type='qcow2'/> <format type='qcow2'/>
<source file='/tmp/logcopy.img'/> <source file='/tmp/logcopy.img' index='1'/>
<backingStore type='block' index='1'> <backingStore type='block' index='2'>
<format type='raw'/> <format type='raw'/>
<source dev='/dev/HostVG/backing'/> <source dev='/dev/HostVG/backing'/>
<backingStore/> <backingStore/>