[PATCH v3 1/4] virsh: avoid unnecessary progress updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is no need to call virshPrintJobProgress() unless the block job's
cur or end cursors have changed since the last iteration.

Signed-off-by: Michael Chapman <mike@xxxxxxxxxxxxxxxxx>
---
 tools/virsh-domain.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index c2146d2..83de02a 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1837,7 +1837,7 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data)
 
     unsigned int abort_flags = 0;
     int ret = -1;
-    virDomainBlockJobInfo info;
+    virDomainBlockJobInfo info, last;
     int result;
 
     if (!data)
@@ -1860,6 +1860,8 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data)
         return -1;
     }
 
+    last.cur = last.end = 0;
+
     while (true) {
         pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask);
         result = virDomainGetBlockJobInfo(data->dom, data->dev, &info, 0);
@@ -1891,9 +1893,10 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data)
             goto cleanup;
         }
 
-        if (data->verbose)
+        if (data->verbose && (info.cur != last.cur || info.end != last.end))
             virshPrintJobProgress(data->job_name, info.end - info.cur,
                                   info.end);
+        last = info;
 
         if (data->timeout && virTimeMillisNow(&curr) < 0) {
             vshSaveLibvirtError();
-- 
2.4.3

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]