mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
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:
parent
fb7a999a81
commit
a87933c66c
@ -1312,16 +1312,13 @@ class vmmDomain(gobject.GObject):
|
||||
logging.debug("Setting boot device to type: %s" % boot_type)
|
||||
|
||||
def set_boot_xml(doc, ctx):
|
||||
ret = ctx.xpathEval("/domain/os/boot[1]")
|
||||
if len(ret) > 0:
|
||||
ret[0].unlinkNode()
|
||||
ret[0].freeNode()
|
||||
emptyxml=doc.serialize()
|
||||
index = emptyxml.find("</os>")
|
||||
newxml = emptyxml[0:index] + \
|
||||
"<boot dev=\"" + boot_type + "\"/>\n" + \
|
||||
emptyxml[index:]
|
||||
return newxml
|
||||
node = ctx.xpathEval("/domain/os/boot[1]")
|
||||
node = (node and node[0] or None)
|
||||
|
||||
if node and node.prop("dev"):
|
||||
node.setProp("dev", boot_type)
|
||||
|
||||
return doc.serialize()
|
||||
|
||||
self.redefine(util.xml_parse_wrapper, set_boot_xml)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user