[virt-tools-list] [virt-manager PATCH 2/2] Fix an exception while a XEN domain is shutting-down

Giuseppe Scrivano gscrivan at redhat.com
Wed Feb 25 15:34:20 UTC 2015


I've noticed twice today that 'guestcpus' was set to 0 while the
domain was shutting down.  Play safe and check that 'guestcpus' is > 0
before divide by it.

Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
 virtManager/domain.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index 2ebceaa..a7c2442 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1513,7 +1513,7 @@ class vmmDomain(vmmLibvirtObject):
             pcentbase = (((cpuTime) * 100.0) /
                          ((now - prevTimestamp) * 1000.0 * 1000.0 * 1000.0))
             pcentHostCpu = pcentbase / hostcpus
-            pcentGuestCpu = pcentbase / guestcpus
+            pcentGuestCpu = guestcpus > 0 and pcentbase / guestcpus or 0
 
         pcentHostCpu = max(0.0, min(100.0, pcentHostCpu))
         pcentGuestCpu = max(0.0, min(100.0, pcentGuestCpu))
-- 
2.1.0




More information about the virt-tools-list mailing list