At least with live block commit, it is possible to have a block
job that reports 0 status: namely, when the active image contains
no sectors that differ from the backing image it is being committed
into [1]. I'm not sure if that represents a qemu bug, but it leads
to weird virsh output where 'virsh blockjob $dom vda' has no output
during a no-op commit job. It appears that the special case for
a zero total was first introduced for migration, where it does sort
of make sense (when we do storage migration, the job is broken up
into two pieces where the first half of migrating storage has no
clue what the total length of the second phase will be, and where
qemu migration always reports a non-zero total length but only once
we complete the first phase to start actual migration), but it
doesn't seem to make sense for any of the block jobs.
[1]
https://www.redhat.com/archives/libvir-list/2015-January/msg00348.html
* tools/virsh-domain.c (vshPrintJobProgress): Move special-case of
0 total...
(vshWatchJob): ...into lone caller where it matters.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
tools/virsh-domain.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 6733cfa..ec62aae 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1,7 +1,7 @@
/*
* virsh-domain.c: Commands to manage domain
*
- * Copyright (C) 2005, 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1678,10 +1678,6 @@ vshPrintJobProgress(const char *label, unsigned long long
remaining,
{
int progress;
- if (total == 0)
- /* migration has not been started */
- return;
-
if (remaining == 0) {
/* migration has completed */
progress = 100;
@@ -4189,7 +4185,7 @@ vshWatchJob(vshControl *ctl,
ret = virDomainGetJobInfo(dom, &jobinfo);
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
if (ret == 0) {
- if (verbose)
+ if (verbose && jobinfo.dataTotal)
vshPrintJobProgress(label, jobinfo.dataRemaining,
jobinfo.dataTotal);
--
2.1.0