]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Reset disk type if <source> element is completely missing
authorPeter Krempa <pkrempa@redhat.com>
Tue, 15 Oct 2019 13:21:21 +0000 (15:21 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 21 Oct 2019 13:59:52 +0000 (15:59 +0200)
The disk type is not part of source and thus it's parsed earlier. This
bypasses the checks when parsing a disk type='network' if it's
completely missing the source.

Since there are possible active users of this (it was reported as a
problem with openstack) fix it by resetting the disk type to '_FILE' for
an empty cdrom which is handled correctly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
tests/qemuxml2xmloutdata/disk-source-pool.xml

index 317e7846ceb0574659b8685087319f0e71c53366..84ae9573dfd431a4927c415d2393edbadda3264a 100644 (file)
@@ -10126,6 +10126,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         }
     }
 
+    /* Reset def->src->type in case when 'source' was not present */
+    if (!source)
+        def->src->type = VIR_STORAGE_TYPE_FILE;
+
     /* Only CDROM and Floppy devices are allowed missing source path
      * to indicate no media present. LUN is for raw access CD-ROMs
      * that are not attached to a physical device presently */
index 78e0449dfdf3478264e112ca40d132df6ba18b8c..807d1099edcd37cc4f8aace7df27bdd8f949bf5c 100644 (file)
@@ -25,7 +25,7 @@
       <readonly/>
       <address type='drive' controller='0' bus='0' target='0' unit='1'/>
     </disk>
-    <disk type='volume' device='cdrom'>
+    <disk type='file' device='cdrom'>
       <driver name='qemu' type='raw'/>
       <target dev='hdc' bus='ide'/>
       <readonly/>