[libvirt] [PATCH v3] virsh nodecpustats returns incorrect stats of cpu on Linux when the number of online cpu exceed 9.

Ján Tomko jtomko at redhat.com
Thu Jan 23 09:47:16 UTC 2014


On 01/21/2014 06:21 AM, mars at linux.vnet.ibm.com wrote:
> From: Bing Bu Cao <mars at linux.vnet.ibm.com>
> 
> To retrieve node cpu statistics on Linux system, the
> linuxNodeGetCPUstats function simply uses STRPREFIX() to match the
> cpuid with the cpuid read from /proc/stat, it will cause
> obvious error.
> 
> For example:
> 'virsh nodecpustats 1' will display stats of cpu1* if the latter is online and cpu1 is offline.
> 
> This patch fixes this bug.
> 
> Signed-off-by: Bing Bu Cao <mars at linux.vnet.ibm.com>
> ---
>  src/nodeinfo.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/nodeinfo.c b/src/nodeinfo.c
> index 05bc038..cf6d29b 100644
> --- a/src/nodeinfo.c
> +++ b/src/nodeinfo.c
> @@ -691,7 +691,7 @@ linuxNodeGetCPUStats(FILE *procstat,
>      char line[1024];
>      unsigned long long usr, ni, sys, idle, iowait;
>      unsigned long long irq, softirq, steal, guest, guest_nice;
> -    char cpu_header[3 + INT_BUFSIZE_BOUND(cpuNum)];
> +    char cpu_header[4 + INT_BUFSIZE_BOUND(cpuNum)];
>  
>      if ((*nparams) == 0) {
>          /* Current number of cpu stats supported by linux */

I have pushed this hunk, Michal pushed the rest from version 2 of the patch.

Could you please take a look at the test I've posted here:
https://www.redhat.com/archives/libvir-list/2014-January/msg01022.html
and extend it with the /proc/stat file from the machine where you saw the failure?

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140123/df4f8d94/attachment-0001.sig>


More information about the libvir-list mailing list