Re: [PATCH] libvirt-guests: emit most messages to stderr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 6 Jan 2016, Martin Kletzander wrote:
On Thu, Dec 31, 2015 at 04:53:54PM +1100, Michael Chapman wrote:
Some of the shell functions in this script (e.g. check_guests_shutdown)
produce output that is captured and processed by other parts of the
script. Any error messages from these shell functions must go to stderr,
not stdout.

Rather than trying to determine which messages are safe for stdout and
which are not (and maintaining this safety as the script is refactored),
simplify things by emitting all messages to stderr, except for the
output from gueststatus(), rh_status() and usage().


This is a good idea, but I just simply changing all outputs to stderr
seems wrong.  It doesn't matter for systemd systems, I guess, we output
everything to stdout currently and it goes to the logs anyway.  But for
other systems it might pollute the output with just informative
messages.  For example on my system I would see stderr but not stdout
(that goes to its logfile).  What is the reasoning behind this change?
Why can't we keep everything on stdout?

I was rebooting a hypervisor with running guests. My libvirt-guests config has:

ON_SHUTDOWN=shutdown PARALLEL_SHUTDOWN=8

I noticed it was taking an awful long time to reboot. What had happened was that it had hit the error path in check_guests_shutdown, so shutdown_guests_parallel was stuck looping over:

virsh domid Failed
virsh domid to
virsh domid determine
virsh domid state
virsh domid of
virsh domid guest
...

The error message had been printed to stdout, so it got captured as the list of guests still needing to be shutdown.

I could have just fixed that one error case (but how? Not use $(...) captures?), but I decided to change them all since it seemed likely that this problem might crop up again in the future.

Can you think of an alternative approach? I hadn't considered the case of systems redirecting only stdout from initscripts.

Signed-off-by: Michael Chapman <mike@xxxxxxxxxxxxxxxxx>
---
 tools/libvirt-guests.sh.in | 94
 +++++++++++++++++++++++-----------------------
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index 7f74b85..80b1ec7 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -92,16 +92,16 @@ test_connect()

     i=${CONNECT_RETRIES}
     while [ $i -gt 0 ]; do
-        run_virsh "$uri" connect 2>/dev/null
+        run_virsh "$uri" connect >/dev/null 2>/dev/null

This could be fixed no matter how we decide to proceed with the rest.

Martin

- Michael

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]