Use proper XML editting when setting boot device.

The current method is ugly and not future proof if extra options are
ever added to the boot list (which is likely).
This commit is contained in:
Cole Robinson 2009-07-02 12:11:28 -04:00
parent fb7a999a81
commit a87933c66c

View File

@ -1312,16 +1312,13 @@ class vmmDomain(gobject.GObject):
logging.debug("Setting boot device to type: %s" % boot_type) logging.debug("Setting boot device to type: %s" % boot_type)
def set_boot_xml(doc, ctx): def set_boot_xml(doc, ctx):
ret = ctx.xpathEval("/domain/os/boot[1]") node = ctx.xpathEval("/domain/os/boot[1]")
if len(ret) > 0: node = (node and node[0] or None)
ret[0].unlinkNode()
ret[0].freeNode() if node and node.prop("dev"):
emptyxml=doc.serialize() node.setProp("dev", boot_type)
index = emptyxml.find("</os>")
newxml = emptyxml[0:index] + \ return doc.serialize()
"<boot dev=\"" + boot_type + "\"/>\n" + \
emptyxml[index:]
return newxml
self.redefine(util.xml_parse_wrapper, set_boot_xml) self.redefine(util.xml_parse_wrapper, set_boot_xml)