[PATCH v2 29/29] conf: Add 'index' attribute for <disk><mirror><source>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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 0970d48045..72dd45feb8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9320,6 +9320,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;

@@ -9335,6 +9336,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",
@@ -9345,7 +9347,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) {
@@ -24032,7 +24035,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)
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 @@
       <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/>
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 @@
       <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/>
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux