]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Properly parse <backingStore/>
authorPeter Krempa <pkrempa@redhat.com>
Wed, 8 Nov 2017 14:42:51 +0000 (15:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 13 Nov 2017 12:13:29 +0000 (13:13 +0100)
The terminator would not be parsed properly since the XPath selector was
looking for an populated element, and also the code did not bother
assigning the terminating virStorageSourcePtr to the backingStore
property of the parent.

Some tests would catch it if there wasn't bigger fallout from the change
to backing store termination in a693fdba0111. Fix them properly now.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1509110

src/conf/domain_conf.c
tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml

index 7dfd7b54e617bf7fa1a97bc90aef2ba5ee952b74..a1ca307c432d6066e0c8765a0564e1ace1cad5a5 100644 (file)
@@ -8545,23 +8545,21 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
     char *idx = NULL;
     int ret = -1;
 
-    if (!(ctxt->node = virXPathNode("./backingStore[*]", ctxt))) {
+    if (!(ctxt->node = virXPathNode("./backingStore", ctxt))) {
         ret = 0;
         goto cleanup;
     }
 
-    if (!(type = virXMLPropString(ctxt->node, "type"))) {
-        /* terminator does not have a type */
-        if (VIR_ALLOC(backingStore) < 0)
-            goto cleanup;
+    if (VIR_ALLOC(backingStore) < 0)
+        goto cleanup;
 
+    /* terminator does not have a type */
+    if (!(type = virXMLPropString(ctxt->node, "type"))) {
+        VIR_STEAL_PTR(src->backingStore, backingStore);
         ret = 0;
         goto cleanup;
     }
 
-    if (VIR_ALLOC(backingStore) < 0)
-        goto cleanup;
-
     if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
         (idx = virXMLPropString(ctxt->node, "index")) &&
         virStrToLong_uip(idx, NULL, 10, &backingStore->id) < 0) {
index 9482b6794adbf6862cc743515db4dafe2860eca6..16caeb354249a499ba885a0416a5c9239aaf1bca 100644 (file)
@@ -22,6 +22,7 @@
     <disk type='file' device='disk'>
       <driver name='qemu' type='raw' cache='none'/>
       <source file='/dev/null'/>
+      <backingStore/>
       <target dev='sdf' bus='scsi'/>
       <readonly/>
       <shareable/>
index 5766e4aea814db404f6308e4f3c42f72d13e595b..cc26af1096adcceb40126f2f8cbb1f4c26380966 100644 (file)
@@ -20,6 +20,7 @@
       <backingStore type='block' index='1'>
         <format type='raw'/>
         <source dev='/dev/HostVG/QEMUGuest1'/>
+        <backingStore/>
       </backingStore>
       <mirror type='block' job='active-commit'>
         <format type='raw'/>
index 828defcc253db147f84b83c503eb6a2b7816b0e9..d1fd2442c35cf7c49cb9f3f919d36349186cc39e 100644 (file)
@@ -49,6 +49,7 @@
                 <backingStore type='file' index='6'>
                   <format type='raw'/>
                   <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/>
+                  <backingStore/>
                 </backingStore>
               </backingStore>
             </backingStore>
@@ -63,6 +64,7 @@
       <source protocol='gluster' name='Volume1/Image'>
         <host name='example.org' port='6000'/>
       </source>
+      <backingStore/>
       <target dev='vdc' bus='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </disk>
@@ -79,6 +81,7 @@
       <backingStore type='file' index='1'>
         <format type='qcow2'/>
         <source file='/tmp/image.qcow'/>
+        <backingStore/>
       </backingStore>
       <target dev='vdd' bus='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
index 252bde3389e75dd752ef4fa551d261768ce71202..c1e8a33ec1c4155c9a9d9376d0d3a9108444125b 100644 (file)
@@ -16,6 +16,7 @@
     <emulator>/usr/bin/qemu-system-i686</emulator>
     <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest1'/>
+      <backingStore/>
       <mirror type='block' job='copy' ready='yes'>
         <source dev='/dev/HostVG/QEMUGuest1Copy'/>
       </mirror>
     </disk>
     <disk type='block' device='cdrom'>
       <source dev='/dev/HostVG/QEMUGuest2'/>
+      <backingStore/>
       <target dev='hdc' bus='ide'/>
       <readonly/>
       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
     </disk>
     <disk type='file' device='disk'>
       <source file='/tmp/data.img'/>
+      <backingStore/>
       <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'>
         <format type='qcow2'/>
         <source file='/tmp/copy.img'/>
@@ -39,6 +42,7 @@
     </disk>
     <disk type='file' device='disk'>
       <source file='/tmp/logs.img'/>
+      <backingStore/>
       <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'>
         <format type='qcow2'/>
         <source file='/tmp/logcopy.img'/>
index f4bd39a58047307e4617475f9e45aaaf3515bde5..e390bc02f2cec8f7b11410f41316e6b327e0eb3e 100644 (file)
@@ -16,6 +16,7 @@
     <emulator>/usr/bin/qemu-system-i686</emulator>
     <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest1'/>
+      <backingStore/>
       <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' job='copy' ready='yes'>
         <source file='/dev/HostVG/QEMUGuest1Copy'/>
       </mirror>
     </disk>
     <disk type='block' device='cdrom'>
       <source dev='/dev/HostVG/QEMUGuest2'/>
+      <backingStore/>
       <target dev='hdc' bus='ide'/>
       <readonly/>
       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
     </disk>
     <disk type='file' device='disk'>
       <source file='/tmp/data.img'/>
+      <backingStore/>
       <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'>
         <format type='qcow2'/>
         <source file='/tmp/copy.img'/>
@@ -39,6 +42,7 @@
     </disk>
     <disk type='file' device='disk'>
       <source file='/tmp/logs.img'/>
+      <backingStore/>
       <target dev='vdb' bus='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </disk>
index 91f573db7da0fd13bed131c9eecf1b5991d190d2..d37b950cbf7f9fe77616424e55120dbce6227d29 100644 (file)
@@ -18,6 +18,7 @@
       <source dev='/dev/HostVG/QEMUGuest1'>
         <seclabel model='selinux' labelskip='yes'/>
       </source>
+      <backingStore/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>