render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
404507
From fee89d5de8520422225dc06fa95cc2dad66d7ebe Mon Sep 17 00:00:00 2001
404507
Message-Id: <fee89d5de8520422225dc06fa95cc2dad66d7ebe@dist-git>
404507
From: Peter Krempa <pkrempa@redhat.com>
404507
Date: Mon, 13 Nov 2017 13:25:01 +0100
404507
Subject: [PATCH] conf: Properly parse <backingStore/>
404507
404507
The terminator would not be parsed properly since the XPath selector was
404507
looking for an populated element, and also the code did not bother
404507
assigning the terminating virStorageSourcePtr to the backingStore
404507
property of the parent.
404507
404507
Some tests would catch it if there wasn't bigger fallout from the change
404507
to backing store termination in a693fdba0111. Fix them properly now.
404507
404507
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1509110
404507
(cherry picked from commit 19448a2561699807c075e071a45df292efd01f6b)
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/conf/domain_conf.c                                 | 18 ++++++++----------
404507
 ...base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml |  1 +
404507
 .../qemuxml2xmlout-disk-active-commit.xml              |  1 +
404507
 .../qemuxml2xmlout-disk-backing-chains-active.xml      |  3 +++
404507
 .../qemuxml2xmlout-disk-mirror-active.xml              |  4 ++++
404507
 .../qemuxml2xmlout-disk-mirror-old.xml                 |  4 ++++
404507
 .../qemuxml2xmlout-seclabel-static-labelskip.xml       |  1 +
404507
 7 files changed, 22 insertions(+), 10 deletions(-)
404507
404507
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
404507
index 27cfecffda..3b337d1a64 100644
404507
--- a/src/conf/domain_conf.c
404507
+++ b/src/conf/domain_conf.c
404507
@@ -8539,16 +8539,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
404507
     char *idx = NULL;
404507
     int ret = -1;
404507
 
404507
-    if (!(ctxt->node = virXPathNode("./backingStore[*]", ctxt))) {
404507
-        ret = 0;
404507
-        goto cleanup;
404507
-    }
404507
-
404507
-    if (!(type = virXMLPropString(ctxt->node, "type"))) {
404507
-        /* terminator does not have a type */
404507
-        if (VIR_ALLOC(backingStore) < 0)
404507
-            goto cleanup;
404507
-
404507
+    if (!(ctxt->node = virXPathNode("./backingStore", ctxt))) {
404507
         ret = 0;
404507
         goto cleanup;
404507
     }
404507
@@ -8556,6 +8547,13 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
404507
     if (VIR_ALLOC(backingStore) < 0)
404507
         goto cleanup;
404507
 
404507
+    /* terminator does not have a type */
404507
+    if (!(type = virXMLPropString(ctxt->node, "type"))) {
404507
+        VIR_STEAL_PTR(src->backingStore, backingStore);
404507
+        ret = 0;
404507
+        goto cleanup;
404507
+    }
404507
+
404507
     if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
404507
         (idx = virXMLPropString(ctxt->node, "index")) &&
404507
         virStrToLong_uip(idx, NULL, 10, &backingStore->id) < 0) {
404507
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
404507
index 9482b6794a..16caeb3542 100644
404507
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
404507
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
404507
@@ -22,6 +22,7 @@
404507
     <disk type='file' device='disk'>
404507
       <driver name='qemu' type='raw' cache='none'/>
404507
       <source file='/dev/null'/>
404507
+      <backingStore/>
404507
       <target dev='sdf' bus='scsi'/>
404507
       <readonly/>
404507
       <shareable/>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml
404507
index 5766e4aea8..cc26af1096 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml
404507
@@ -20,6 +20,7 @@
404507
       <backingStore type='block' index='1'>
404507
         <format type='raw'/>
404507
         <source dev='/dev/HostVG/QEMUGuest1'/>
404507
+        <backingStore/>
404507
       </backingStore>
404507
       <mirror type='block' job='active-commit'>
404507
         <format type='raw'/>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml
404507
index 828defcc25..d1fd2442c3 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml
404507
@@ -49,6 +49,7 @@
404507
                 <backingStore type='file' index='6'>
404507
                   <format type='raw'/>
404507
                   <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/>
404507
+                  <backingStore/>
404507
                 </backingStore>
404507
               </backingStore>
404507
             </backingStore>
404507
@@ -63,6 +64,7 @@
404507
       <source protocol='gluster' name='Volume1/Image'>
404507
         <host name='example.org' port='6000'/>
404507
       </source>
404507
+      <backingStore/>
404507
       <target dev='vdc' bus='virtio'/>
404507
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
404507
     </disk>
404507
@@ -79,6 +81,7 @@
404507
       <backingStore type='file' index='1'>
404507
         <format type='qcow2'/>
404507
         <source file='/tmp/image.qcow'/>
404507
+        <backingStore/>
404507
       </backingStore>
404507
       <target dev='vdd' bus='virtio'/>
404507
       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml
404507
index 252bde3389..c1e8a33ec1 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml
404507
@@ -16,6 +16,7 @@
404507
     <emulator>/usr/bin/qemu-system-i686</emulator>
404507
     <disk type='block' device='disk'>
404507
       <source dev='/dev/HostVG/QEMUGuest1'/>
404507
+      <backingStore/>
404507
       <mirror type='block' job='copy' ready='yes'>
404507
         <source dev='/dev/HostVG/QEMUGuest1Copy'/>
404507
       </mirror>
404507
@@ -24,12 +25,14 @@
404507
     </disk>
404507
     <disk type='block' device='cdrom'>
404507
       <source dev='/dev/HostVG/QEMUGuest2'/>
404507
+      <backingStore/>
404507
       <target dev='hdc' bus='ide'/>
404507
       <readonly/>
404507
       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
404507
     </disk>
404507
     <disk type='file' device='disk'>
404507
       <source file='/tmp/data.img'/>
404507
+      <backingStore/>
404507
       <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'>
404507
         <format type='qcow2'/>
404507
         <source file='/tmp/copy.img'/>
404507
@@ -39,6 +42,7 @@
404507
     </disk>
404507
     <disk type='file' device='disk'>
404507
       <source file='/tmp/logs.img'/>
404507
+      <backingStore/>
404507
       <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'>
404507
         <format type='qcow2'/>
404507
         <source file='/tmp/logcopy.img'/>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
404507
index f4bd39a580..e390bc02f2 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
404507
@@ -16,6 +16,7 @@
404507
     <emulator>/usr/bin/qemu-system-i686</emulator>
404507
     <disk type='block' device='disk'>
404507
       <source dev='/dev/HostVG/QEMUGuest1'/>
404507
+      <backingStore/>
404507
       <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' job='copy' ready='yes'>
404507
         <source file='/dev/HostVG/QEMUGuest1Copy'/>
404507
       </mirror>
404507
@@ -24,12 +25,14 @@
404507
     </disk>
404507
     <disk type='block' device='cdrom'>
404507
       <source dev='/dev/HostVG/QEMUGuest2'/>
404507
+      <backingStore/>
404507
       <target dev='hdc' bus='ide'/>
404507
       <readonly/>
404507
       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
404507
     </disk>
404507
     <disk type='file' device='disk'>
404507
       <source file='/tmp/data.img'/>
404507
+      <backingStore/>
404507
       <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'>
404507
         <format type='qcow2'/>
404507
         <source file='/tmp/copy.img'/>
404507
@@ -39,6 +42,7 @@
404507
     </disk>
404507
     <disk type='file' device='disk'>
404507
       <source file='/tmp/logs.img'/>
404507
+      <backingStore/>
404507
       <target dev='vdb' bus='virtio'/>
404507
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
404507
     </disk>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml
404507
index 91f573db7d..d37b950cbf 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml
404507
@@ -18,6 +18,7 @@
404507
       <source dev='/dev/HostVG/QEMUGuest1'>
404507
         <seclabel model='selinux' labelskip='yes'/>
404507
       </source>
404507
+      <backingStore/>
404507
       <target dev='hda' bus='ide'/>
404507
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
404507
     </disk>
404507
-- 
404507
2.15.0
404507