1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

virsh: fix return value error of cpu-stats

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
This commit is contained in:
Guannan Ren 2013-08-23 18:17:25 +08:00
parent a88924bc21
commit 9eb444364e

View File

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