Signed-off-by: Nitesh Konkar <nitko...@linux.vnet.ibm.com>
---
# virsh cpu-stats --domain 40 --start 159
CPU159:
        cpu_time             0.000000000 seconds
        vcpu_time            0.000000000 seconds

# virsh cpu-stats --domain 40 --start 160
Start cpu 160 larger than maximum of 159.

 tools/virsh-domain.c | 6 ++++++
 1 files changed, 6 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 800829e..3d6b626 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7357,6 +7357,12 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
     /* get number of cpus on the node */
     if ((max_id = virDomainGetCPUStats(dom, NULL, 0, 0, 0, 0)) < 0)
         goto failed_stats;
+
+    if (cpu >= max_id) {
+        vshPrint(ctl, "Start cpu %d larger than maximum of %d.", cpu, max_id - 
1);
+        goto cleanup;
+    }
+
     if (show_count < 0 || show_count > max_id) {
         if (show_count > max_id)
             vshPrint(ctl, _("Only %d CPUs available to show\n"), max_id);
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to