]> git.ipfire.org Git - thirdparty/libvirt.git/commit
cpustat: fix regression when cpus are offline
authorEric Blake <eblake@redhat.com>
Thu, 25 Oct 2012 20:44:32 +0000 (14:44 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 26 Oct 2012 21:34:52 +0000 (15:34 -0600)
commit4fbf322fe9b23b247d203e627ce3ac4125445b63
tree0083e6ae57fba5821630305e22a83a150bb953f6
parent07049e4c39186368d6851df9707a53525a3f06a0
cpustat: fix regression when cpus are offline

It turns out that the cpuacct results properly account for offline
cpus, and always returns results for every possible cpu, not just
the online ones.  So there is no need to check the map of online
cpus in the first place, merely only a need to know the maximum
possible cpu.  Meanwhile, virNodeGetCPUBitmap had a subtle change
from returning the maximum id to instead returning the width of
the bitmap (one larger than the maximum id) in commit 2f4c5338,
which made this code encounter some off-by-one logic leading to
bad error messages when a cpu was offline:

$ virsh cpu-stats dom
error: Failed to virDomainGetCPUStats()

error: An error occurred, but the cause is unknown

Cleaning this up unraveled a chain of other unused variables.

* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Drop
pointless check for cpumap changes, and use correct number of
cpus.  Simplify signature.
(qemuDomainGetCPUStats): Adjust caller.
* src/nodeinfo.h (nodeGetCPUCount): New prototype.
(nodeGetCPUBitmap): Drop unused parameter.
* src/nodeinfo.c (nodeGetCPUBitmap): Likewise.
(nodeGetCPUMap): Adjust caller.
(nodeGetCPUCount): New function.
* src/libvirt_private.syms (nodeinfo.h): Export it.
src/libvirt_private.syms
src/nodeinfo.c
src/nodeinfo.h
src/qemu/qemu_driver.c