提交 4cd3f241 编写于 作者: W Wim ten Have 提交者: Jim Fehlig

xenconfig: fix handling of NULL disk source

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: NWim ten Have <wim.ten.have@oracle.com>
上级 2f69dd36
...@@ -316,6 +316,10 @@ xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr) ...@@ -316,6 +316,10 @@ xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr)
char *tmpstr = NULL; char *tmpstr = NULL;
int ret = -1; int ret = -1;
/* A NULL source is valid, e.g. an empty CDROM */
if (srcstr == NULL)
return 0;
if (STRPREFIX(srcstr, "rbd:")) { if (STRPREFIX(srcstr, "rbd:")) {
if (!(tmpstr = virStringReplace(srcstr, "\\\\", "\\"))) if (!(tmpstr = virStringReplace(srcstr, "\\\\", "\\")))
goto cleanup; goto cleanup;
......
...@@ -22,4 +22,4 @@ parallel = "none" ...@@ -22,4 +22,4 @@ parallel = "none"
serial = "none" serial = "none"
builder = "hvm" builder = "hvm"
boot = "d" 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" ]
...@@ -39,6 +39,12 @@ ...@@ -39,6 +39,12 @@
<readonly/> <readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/> <address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk> </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'/> <controller type='ide' index='0'/>
<interface type='bridge'> <interface type='bridge'>
<mac address='00:16:3e:66:92:9c'/> <mac address='00:16:3e:66:92:9c'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册