From f5751bfea7582a608478b296356ac5cafdd47f6a Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Sat, 4 Jun 2011 02:44:27 +0200 Subject: [PATCH] dom0: prevent division by zero on calculating cpu usage When VM is starting online_vcpus=0 for short time. --- dom0/qvm-core/qubes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index a4678a65..d289f9d6 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -140,7 +140,7 @@ class QubesHost(object): info = xc.domain_getinfo(0, qubes_max_xid) for vm in info: current[vm['domid']] = {} - current[vm['domid']]['cpu_time'] = vm['cpu_time']/vm['online_vcpus'] + current[vm['domid']]['cpu_time'] = vm['cpu_time']/max(vm['online_vcpus'],1) if vm['domid'] in previous.keys(): current[vm['domid']]['cpu_usage'] = \ float(current[vm['domid']]['cpu_time'] - previous[vm['domid']]['cpu_time']) \