From a87933c66cc0bf74ba88fc563dd2cf18c352227f Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 2 Jul 2009 12:11:28 -0400 Subject: [PATCH] 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). --- src/virtManager/domain.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py index af5f83c05..f0f427ece 100644 --- a/src/virtManager/domain.py +++ b/src/virtManager/domain.py @@ -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("") - newxml = emptyxml[0:index] + \ - "\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)