]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: fix return value error of cpu-stats
authorGuannan Ren <gren@redhat.com>
Fri, 23 Aug 2013 10:17:25 +0000 (18:17 +0800)
committerGuannan Ren <gren@redhat.com>
Tue, 27 Aug 2013 07:17:03 +0000 (15:17 +0800)
virsh cpu-stats guest --start 0 --count 3
It outputs right but the return value is 1 rather than 0
echo $?
1

Found by running libvirt-autotest
./run -t libvirt --tests virsh_cpu_stats

tools/virsh-domain.c

index 5d4913d89db5aa271bce89912cb8fe924ce5eb2c..83b9c3f6a88388f5b4323666dba2869705d4c112 100644 (file)
@@ -6350,7 +6350,9 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
 
     if (!nparams) {
         vshPrint(ctl, "%s", _("No per-CPU stats available"));
-        goto do_show_total;
+        if (show_total)
+            goto do_show_total;
+        goto cleanup;
     }
 
     if (VIR_ALLOC_N(params, nparams * MIN(show_count, 128)) < 0)
@@ -6389,10 +6391,12 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
     }
     VIR_FREE(params);
 
-do_show_total:
-    if (!show_total)
+    if (!show_total) {
+        ret = true;
         goto cleanup;
+    }
 
+do_show_total:
     /* get supported num of parameter for total statistics */
     if ((nparams = virDomainGetCPUStats(dom, NULL, 0, -1, 1, flags)) < 0)
         goto failed_stats;