virshPrintJobProgress pretty-prints a migration progress indicator on stderr presuming it's tied to a tty, which is not always true.
In the case without the tty, I still find the progress indication useful (for instance it ends in a timestamped log, which is useful for debug/perf analysis). And most log processings are line-buffered, thus it won't properly work until every progress update ends with a newline. I had a quick glance and did not find any other place in virsh code where a tty was assumed, thus I thought this tty-awareness could be narrowed to this single function. This was originally submited as https://gitlab.com/libvirt/libvirt/-/issues/756 Signed-off-by: Vincent Caron <vca...@bearstech.com> --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1bee969824..577ab57158 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2108,7 +2108,7 @@ virshPrintJobProgress(const char *label, unsigned long long remaining, /* see comments in vshError about why we must flush */ fflush(stdout); /* avoid auto-round-off of double by keeping only 2 decimals */ - fprintf(stderr, "\r%s: [%5.2f %%]", label, (int)(progress*100)/100.0); + fprintf(stderr, isatty(STDERR_FILENO) ? "\r%s: [%5.2f %%]" : "%s: [%5.2f %%]\n", label, (int)(progress*100)/100.0); fflush(stderr); } -- 2.39.5