From: Peter Krempa Date: Tue, 15 Oct 2019 13:21:21 +0000 (+0200) Subject: conf: Reset disk type if element is completely missing X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2c37dc7bda1aa041650e4960c327bfdc9a6e4b73;p=libvirt.git conf: Reset disk type if element is completely missing 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 Reviewed-by: Michal Privoznik --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 317e7846ce..84ae9573df 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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 */ diff --git a/tests/qemuxml2xmloutdata/disk-source-pool.xml b/tests/qemuxml2xmloutdata/disk-source-pool.xml index 78e0449dfd..807d1099ed 100644 --- a/tests/qemuxml2xmloutdata/disk-source-pool.xml +++ b/tests/qemuxml2xmloutdata/disk-source-pool.xml @@ -25,7 +25,7 @@
- +