]> xenbits.xensource.com Git - libvirt.git/commit
linuxNodeGetCPUStats: Correctly handle cpu prefix
authorBing Bu Cao <mars@linux.vnet.ibm.com>
Thu, 16 Jan 2014 08:18:09 +0000 (16:18 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 21 Jan 2014 16:24:03 +0000 (17:24 +0100)
commit94f82053590795a67bd5fb38026c86fb5329e7b7
tree8d4e2ae066ef36e34e45905ea5e52e8123711f4f
parent9d6f26e57c4195c306c2fecff8ff4dba1dcd7e34
linuxNodeGetCPUStats: Correctly handle cpu prefix

To retrieve node cpu statistics on Linux system, the
linuxNodeGetCPUstats function simply uses STRPREFIX() to match the cpuid
with the one read from /proc/stat. However, as the file is read line by
line it may happen, that some CPUs share the same prefix. So if user
requested stats for the first CPU, which is offline, then there's no
cpu1 in the stats file so the one that we match is cpu10. Which is
obviously wrong. Fortunately, the IDs are terminated by a space, so we
can utilize that.

Signed-off-by: Bing Bu Cao <mars@linux.vnet.ibm.com>
src/nodeinfo.c