From 0ed35e0939c8ee2c38dbb4d67233e864499287ee Mon Sep 17 00:00:00 2001 From: Nitesh Konkar Date: Fri, 15 Apr 2016 03:28:53 -0400 Subject: [PATCH] Return error when --start in cpu-stats is invalid. Signed-off-by: Nitesh Konkar --- tools/virsh-domain.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 800829eaea..a1d4a75747 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7357,6 +7357,13 @@ 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) { + vshError(ctl, "Start CPU %d is out of range (min: 0, max: %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); -- GitLab