add qemu_error() + friends
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 14 Aug 2009 08:36:06 +0000 (10:36 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 28 Aug 2009 01:43:33 +0000 (20:43 -0500)
commite52fcf9ad7362e0657e8f790436c83806411501e
tree61b23e3a7f491b9f5939f03ab77527e9183be0cb
parent77ee233416a8285758b5c66174f7b368132cbf16
add qemu_error() + friends

This patch adds some functions for error reporting to address the
problem that error messages should be routed to different destinations
depending on the context of the caller, i.e. monitor command errors
should go to the monitor, command line errors to stderr.

qemu_error() is a printf-like function to report errors.

qemu_errors_to_file() and qemu_errors_to_mon() switch the destination
for the error message to the specified file or monitor.  When setting a
new destination the old one will be kept.  One can switch back using
qemu_errors_to_previous().  i.e. it works like a stack.

main() calls qemu_errors_to_file(stderr), so errors go to stderr by
default.  monitor callbacks are wrapped into qemu_errors_to_mon() +
qemu_errors_to_previous(), so any errors triggered by monitor commands
will go to the monitor.

Each thread has its own error message destination.  qemu-kvm probably
should add a qemu_errors_to_file(stderr) call to the i/o-thread
initialization code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
monitor.c
sysemu.h
vl.c