提交 704dfd6b 编写于 作者: M Michael Chapman 提交者: Peter Krempa

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: NMichael Chapman <mike@very.puzzling.org>
上级 92549b3b
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册