]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xenconfig: fix handling of NULL disk source
authorWim ten Have <wim.ten.have@oracle.com>
Fri, 19 May 2017 14:38:43 +0000 (16:38 +0200)
committerJim Fehlig <jfehlig@suse.com>
Fri, 19 May 2017 14:47:36 +0000 (08:47 -0600)
It is possible to crash libvirtd when converting xl native config to
domXML when the xl config contains an empty disk source, e.g. an empty
CDROM. Fix by checking that the disk source is non-NULL before parsing it.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
src/xenconfig/xen_xl.c
tests/xlconfigdata/test-disk-positional-parms-partial.cfg
tests/xlconfigdata/test-disk-positional-parms-partial.xml

index 4f24d457c8c60e6d84453d738fa867a8e769a89f..cac440cd450bd064cf6aba40ac11786501867f46 100644 (file)
@@ -316,6 +316,10 @@ xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr)
     char *tmpstr = NULL;
     int ret = -1;
 
+    /* A NULL source is valid, e.g. an empty CDROM */
+    if (srcstr == NULL)
+        return 0;
+
     if (STRPREFIX(srcstr, "rbd:")) {
         if (!(tmpstr = virStringReplace(srcstr, "\\\\", "\\")))
             goto cleanup;
index fd16db04c19894835e8746a710e0659360ee1e43..940304e7b2187cef3b6b9d9c42a202d2c8dfc4f7 100644 (file)
@@ -22,4 +22,4 @@ parallel = "none"
 serial = "none"
 builder = "hvm"
 boot = "d"
-disk = [ "/dev/HostVG/XenGuest2,,hda,,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,,hdb,,", "/root/boot.iso,,hdc,,devtype=cdrom" ]
+disk = [ "/dev/HostVG/XenGuest2,,hda,,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,,hdb,,", "/root/boot.iso,,hdc,,devtype=cdrom" , "format=raw,vdev=hdd,access=ro,devtype=cdrom" ]
index e86a5be192891493b1641bbe9a0016cce2def268..52b21dc59247bb40b1f958f6ac7f60688cf1ce4a 100644 (file)
       <readonly/>
       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
     </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <target dev='hdd' bus='ide'/>
+      <readonly/>
+      <address type='drive' controller='0' bus='1' target='0' unit='1'/>
+    </disk>
     <controller type='ide' index='0'/>
     <interface type='bridge'>
       <mac address='00:16:3e:66:92:9c'/>