]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Add 'index' attribute for <disk><mirror><source>
authorPeter Krempa <pkrempa@redhat.com>
Wed, 13 Mar 2019 16:42:37 +0000 (17:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 3 Apr 2019 09:58:09 +0000 (11:58 +0200)
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>
src/conf/domain_conf.c
tests/qemuxml2argvdata/disk-mirror.xml
tests/qemuxml2xmloutdata/disk-mirror-active.xml

index c38102a5103c59ac7feb984367cbd0c46433bc2c..bbde3788a6e96b719edc8b404d01bee4e21099a9 100644 (file)
@@ -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, "<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;
 
     if (virDomainDiskBackingStoreFormat(&childBuf, disk->mirror, xmlopt, flags) < 0)
index c1e6e94e3314884d6045a3de30f74d5f50291a8a..5a825c54ac6f4fbc1a124f678f56a147574c8e34 100644 (file)
@@ -45,8 +45,8 @@
       <backingStore/>
       <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'>
         <format type='qcow2'/>
-        <source file='/tmp/logcopy.img'/>
-        <backingStore type='block' index='1'>
+        <source file='/tmp/logcopy.img' index='1'/>
+        <backingStore type='block' index='2'>
           <format type='raw'/>
           <source dev='/dev/HostVG/backing'/>
           <backingStore/>
index 32ffc647bec47964b869b5e6fad4895b48765348..bebdb849c210b4c6a9ca2160e77bb5db93e517ee 100644 (file)
@@ -51,8 +51,8 @@
       <backingStore/>
       <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'>
         <format type='qcow2'/>
-        <source file='/tmp/logcopy.img'/>
-        <backingStore type='block' index='1'>
+        <source file='/tmp/logcopy.img' index='1'/>
+        <backingStore type='block' index='2'>
           <format type='raw'/>
           <source dev='/dev/HostVG/backing'/>
           <backingStore/>