/dev/null should not be passed as source dev for cdrom device.
This patch verifies that source dev only has non null and
non /dev/null values for cdrom device.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 343dc9e..ee20895 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -65,10 +65,12 @@ static char *disk_block_xml(xmlNodePtr root, struct
disk_device *dev)
xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->
cache);
}
- tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
- if (tmp == NULL)
- return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->source);
+ if ((dev->source != NULL) && (!XSTREQ(dev->source,
"/dev/null")))
{
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->source);
+ }
tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL);
if (tmp == NULL)