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

Nitesh Konkar niteshkonkar.libvirt at gmail.com
Fri Apr 1 06:05:04 UTC 2016


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 at 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




More information about the libvir-list mailing list