Skip to content

virshPrintJobProgress is not tty-aware

I mostly run virsh commands remotely through non-interactive SSH sessions, from glue scripts. In this case the remote commands don't have a tty, the control script might not even have a tty (eg: cron context).

It's also very useful for me that all command outputs, including errors/stderr, are "loggable", which also implies that the command does not try to play with the terminal cursor.

The problem materializes for me in virsh migrate, I either get "funny" logs, or no progress at all due to my stderr post-processing which has to be line-buffered. It seems that in virsh's code, only tools/virsh-domain.c:virshPrintJobProgress expects stderr to be a tty. What would you think of a patch like :

    if (isatty(stderr))
        fprintf(stderr, "\r%s: [%5.2f %%]", label, (int)(progress*100)/100.0);
    else
        fprintf(stderr, "%s: [%5.2f %%]\n", label, (int)(progress*100)/100.0);
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information