Handle the case where the source device and source type are null -- for example, if a cdrom device exists in the guest config but is not mapped to a backend device.

This commit is contained in:
Hugh O. Brock 2007-05-24 16:49:13 -04:00
parent c3b4a9da71
commit aec4d3853b

View File

@ -456,23 +456,28 @@ class vmmDomain(gobject.GObject):
type = node.prop("type") type = node.prop("type")
srcpath = None srcpath = None
devdst = None devdst = None
devtype = node.prop("device")
if devtype == None:
devtype = "disk"
for child in node.children: for child in node.children:
if child.name == "source": if child.name == "source":
if type == "file": if type == "file":
srcpath = child.prop("file") srcpath = child.prop("file")
elif type == "block": elif type == "block":
srcpath = child.prop("dev") srcpath = child.prop("dev")
elif type == None:
type = "-"
elif child.name == "target": elif child.name == "target":
devdst = child.prop("dev") devdst = child.prop("dev")
if srcpath == None: if srcpath == None:
raise RuntimeError("missing source path") if devtype == "cdrom":
srcpath = "-"
type = "block"
else:
raise RuntimeError("missing source path")
if devdst == None: if devdst == None:
raise RuntimeError("missing destination device") raise RuntimeError("missing destination device")
devtype = node.prop("device")
if devtype == None:
devtype = "disk"
disks.append([type, srcpath, devtype, devdst]) disks.append([type, srcpath, devtype, devdst])
finally: finally: