virsh: avoid unnecessary progress updates

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@very.puzzling.org>
This commit is contained in:
Michael Chapman 2016-01-27 13:24:51 +11:00 committed by Peter Krempa
parent 92549b3b8a
commit 704dfd6b0f
1 changed files with 5 additions and 2 deletions

View File

@ -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();