[Kimchi-devel] [PATCH] bug fix: Properly check if there running vms before rebooting system

Aline Manera alinefm at linux.vnet.ibm.com
Tue Feb 18 20:03:53 UTC 2014


From: Aline Manera <alinefm at br.ibm.com>

The user only can reboot or shutdown the host if there is no running
virtual machine.
During the model refactoring it kept using the function vms_get_list()
which does not exist in the host view.
So fix it.

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 src/kimchi/model/host.py |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index fc4f386..759f13e 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -45,6 +45,7 @@ HOST_STATS_INTERVAL = 1
 
 class HostModel(object):
     def __init__(self, **kargs):
+        self.conn = kargs['conn']
         self.host_info = self._get_host_info()
 
     def _get_host_info(self):
@@ -100,9 +101,13 @@ class HostModel(object):
         os.system('reboot')
 
     def _get_vms_list_by_state(self, state):
+        conn = self.conn.get()
+        names = [dom.name().decode('utf-8') for dom in conn.listAllDomains(0)]
+
         ret_list = []
-        for name in self.vms_get_list():
-            info = self._get_vm(name).info()
+        for name in names:
+            dom = conn.lookupByName(name.encode("utf-8"))
+            info = dom.info()
             if (DOM_STATE_MAP[info[0]]) == state:
                 ret_list.append(name)
         return ret_list
-- 
1.7.10.4




More information about the Kimchi-devel mailing list