[libvirt] [PATCH 31/34] conf: Add 'index' attribute for <disk><mirror><source>

Peter Krempa posted 34 patches 6 years, 10 months ago
There is a newer version of this series
[libvirt] [PATCH 31/34] conf: Add 'index' attribute for <disk><mirror><source>
Posted by Peter Krempa 6 years, 10 months ago
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>
---
 src/conf/domain_conf.c                          | 4 ++--
 tests/qemuxml2argvdata/disk-mirror.xml          | 4 ++--
 tests/qemuxml2xmloutdata/disk-mirror-active.xml | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 585b5515f9..2bb4d6eafc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9364,7 +9364,7 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
         if (!(def->mirror = virDomainStorageSourceParseFull("string(./@type)",
                                                             NULL,
                                                             "./source",
-                                                            NULL,
+                                                            "string(./source/@index)",
                                                             false, true, ctxt, flags, xmlopt)))
             return -1;

@@ -24130,7 +24130,7 @@ virDomainDiskDefFormatMirror(virBufferPtr buf,
     virBufferAddLit(buf, ">\n");
     virBufferAdjustIndent(buf, 2);
     virBufferEscapeString(buf, "<format type='%s'/>\n", formatStr);
-    if (virDomainDiskSourceFormat(buf, disk->mirror, 0, flags, true, false, true,
+    if (virDomainDiskSourceFormat(buf, disk->mirror, 0, flags, true, true, true,
                                   xmlopt) < 0)
         return -1;
     virBufferAdjustIndent(buf, -2);
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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 31/34] conf: Add 'index' attribute for <disk><mirror><source>
Posted by Ján Tomko 6 years, 10 months ago
On Mon, Mar 18, 2019 at 04:55:20PM +0100, Peter Krempa wrote:
>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>
>---
> src/conf/domain_conf.c                          | 4 ++--
> tests/qemuxml2argvdata/disk-mirror.xml          | 4 ++--
> tests/qemuxml2xmloutdata/disk-mirror-active.xml | 4 ++--
> 3 files changed, 6 insertions(+), 6 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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