[libvirt] [PATCH] Pass the correct cpu count when calling virDomainGetCPUStats.

When using the --start option, the show_count should not be set to max_id as the --start <cpu> means we dont need those many inital cpu stats. Hence, show_count should be adjusted accordingly. Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com> --- Before Patch: virsh cpu-stats --domain 24 --start 158 CPU158: cpu_time 0.073570788 seconds vcpu_time 0.033277032 seconds CPU159: cpu_time 0.000000000 seconds vcpu_time 0.000000000 seconds error: Failed to retrieve CPU statistics for domain 24 error: invalid argument: start_cpu 280 larger than maximum of 159 After Patch: virsh cpu-stats --domain 24 --start 158 CPU158: cpu_time 0.073570788 seconds vcpu_time 0.033277032 seconds CPU159: cpu_time 0.000000000 seconds vcpu_time 0.000000000 seconds tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index bb1ee1c..7599bdc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7331,7 +7331,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) if (show_count < 0 || show_count > max_id) { if (show_count > max_id) vshPrint(ctl, _("Only %d CPUs available to show\n"), max_id); - show_count = max_id; + show_count = max_id - cpu; } /* get percpu information */ -- 1.8.3.1

On Fri, Apr 01, 2016 at 02:05:04AM -0400, Nitesh Konkar wrote:
When using the --start option, the show_count should not be set to max_id as the --start <cpu> means we dont need those many inital cpu stats. Hence, show_count should be adjusted accordingly.
There is a public bug filed for this: https://bugzilla.redhat.com/show_bug.cgi?id=1249441 I have added the link to the commit message.
Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com> --- Before Patch: virsh cpu-stats --domain 24 --start 158 CPU158: cpu_time 0.073570788 seconds vcpu_time 0.033277032 seconds
CPU159: cpu_time 0.000000000 seconds vcpu_time 0.000000000 seconds error: Failed to retrieve CPU statistics for domain 24 error: invalid argument: start_cpu 280 larger than maximum of 159
After Patch: virsh cpu-stats --domain 24 --start 158 CPU158: cpu_time 0.073570788 seconds vcpu_time 0.033277032 seconds
CPU159: cpu_time 0.000000000 seconds vcpu_time 0.000000000 seconds
tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ACK and pushed Jan
participants (2)
-
Ján Tomko
-
Nitesh Konkar