[Kimchi-devel] [PATCH 3/6] Check currentMemory exists prior to remote its XML node

Aline Manera alinefm at linux.vnet.ibm.com
Tue Nov 11 20:46:25 UTC 2014


When updating the guest memory, the currentMemory node must be removed
to reflect the new value.
But it the guest was never started it does not have a currentMemory
node. So check it is exists first prior to remove it.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/kimchi/model/vms.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index d194049..d13732b 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -650,7 +650,9 @@ class VMModel(object):
                 dom.undefine()
 
             root = ET.fromstring(new_xml)
-            root.remove(root.find('.currentMemory'))
+            currentMem = root.find('.currentMemory')
+            if currentMem is not None:
+                root.remove(currentMem)
             dom = conn.defineXML(ET.tostring(root, encoding="utf-8"))
         except libvirt.libvirtError as e:
             dom = conn.defineXML(old_xml)
-- 
1.9.3




More information about the Kimchi-devel mailing list