Fix an exception while a XEN domain is shutting-down

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@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2015-02-25 16:27:16 +01:00
parent 64264e8fa2
commit ef286321f9

View File

@ -1513,7 +1513,9 @@ class vmmDomain(vmmLibvirtObject):
pcentbase = (((cpuTime) * 100.0) /
((now - prevTimestamp) * 1000.0 * 1000.0 * 1000.0))
pcentHostCpu = pcentbase / hostcpus
pcentGuestCpu = pcentbase / guestcpus
# Under RHEL-5.9 using a XEN HV guestcpus can be 0 during shutdown
# so play safe and check it.
pcentGuestCpu = guestcpus > 0 and pcentbase / guestcpus or 0
pcentHostCpu = max(0.0, min(100.0, pcentHostCpu))
pcentGuestCpu = max(0.0, min(100.0, pcentGuestCpu))