[Kimchi-devel] [PATCH 2/3] Update some VM state conditions

Crístian Viana vianac at linux.vnet.ibm.com
Thu Jan 22 14:52:18 UTC 2015


Some functions assume that a VM can only be in two states: shutoff and
running. However, that's not always the case (e.g. not being running
doesn't mean it's shutoff).

Update some functions so the VM state conditions are more accurate.

Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
---
 src/kimchi/model/vms.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 42cf3e9..5128d1e 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -683,7 +683,7 @@ class VMModel(object):
         try:
             if 'name' in params:
                 state = DOM_STATE_MAP[dom.info()[0]]
-                if state == 'running':
+                if state != u'shutoff':
                     msg_args = {'name': dom.name(), 'new_name': params['name']}
                     raise InvalidParameter("KCHVM0003E", msg_args)
 
@@ -788,7 +788,7 @@ class VMModel(object):
         paths = self._vm_get_disk_paths(dom)
         info = self.lookup(name)
 
-        if info['state'] == 'running':
+        if info['state'] != u'shutoff':
             self.poweroff(name)
 
         # delete existing snapshots before deleting VM
-- 
2.1.0




More information about the Kimchi-devel mailing list