]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: remove unnecessary sleep for nodecpustats --percent
authorViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Fri, 13 Jul 2012 07:50:25 +0000 (09:50 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 13 Jul 2012 09:32:07 +0000 (11:32 +0200)
Fix for a minor issue:
the sleep(1) statement was called twice,
effectively doubling the elapsed time
execution "virsh nodecpustats --percent".

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
tools/virsh.c

index 126aa3b273ba041ebae41c4f8dd2a467b2fd533f..f9fe4b1e7b55fd15fa03e2bada05f7d09e898142 100644 (file)
@@ -6840,8 +6840,10 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
     memset(cpu_stats, 0, sizeof(cpu_stats));
     params = vshCalloc(ctl, nparams, sizeof(*params));
 
-    i = 0;
-    do {
+    for (i = 0; i < 2; i++) {
+        if (i > 0)
+            sleep(1);
+
         if (virNodeGetCPUStats(ctl->conn, cpuNum, params, &nparams, 0) != 0) {
             vshError(ctl, "%s", _("Unable to get node cpu stats"));
             goto cleanup;
@@ -6866,10 +6868,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
 
         if (flag_utilization || !flag_percent)
             break;
-
-        i++;
-        sleep(1);
-    } while (i < 2);
+    }
 
     if (!flag_percent) {
         if (!flag_utilization) {