[Kimchi-devel] [PATCH v2 1/3] Optimize VM update function

Crístian Deives cristiandeives at gmail.com
Wed Apr 8 12:28:59 UTC 2015


From: Crístian Viana <vianac at linux.vnet.ibm.com>

When updating a VM, Kimchi always fetches the current VM state
regardless of whether it will be needed.

Move the VM state fetching to block where it's needed. That way, Kimchi
will save a libvirt call when that result isn't important for the
operation.

Signed-off-by: Crístian Deives <cristiandeives at gmail.com>
---
 src/kimchi/model/vms.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index af5e765..c39a407 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -732,7 +732,6 @@ class VMModel(object):
             dom.snapshotCreateXML(info['xml'], flags)
 
     def _static_vm_update(self, dom, params):
-        state = DOM_STATE_MAP[dom.info()[0]]
         old_xml = new_xml = dom.XMLDesc(0)
 
         for key, val in params.items():
@@ -754,6 +753,7 @@ class VMModel(object):
         conn = self.conn.get()
         try:
             if 'name' in params:
+                state = DOM_STATE_MAP[dom.info()[0]]
                 if state == 'running':
                     msg_args = {'name': vm_name, 'new_name': params['name']}
                     raise InvalidParameter("KCHVM0003E", msg_args)
-- 
2.1.0




More information about the Kimchi-devel mailing list