qemu-patch-raspberry4/qemu-error.c
Markus Armbruster 6e4f984cb9 error: Simplify error sink setup
qemu_error_sink can either point to a monitor or a file.  In practice,
it always points to the current monitor if we have one, else to
stderr.  Simply route errors to the current monitor or else to stderr,
and remove qemu_error_sink along with the functions to control it.

Actually, the old code switches the sink slightly later, in
handle_user_command() and handle_qmp_command(), than it gets switched
now, implicitly, by setting the current monitor in monitor_read() and
monitor_control_read().  Likewise, it switches back slightly earlier
(same places).  Doesn't make a difference, because there are no calls
of qemu_error() in between.
2010-03-16 16:55:05 +01:00

35 lines
685 B
C

#include <stdio.h>
#include "monitor.h"
#include "sysemu.h"
void qemu_error(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
if (cur_mon) {
monitor_vprintf(cur_mon, fmt, args);
} else {
vfprintf(stderr, fmt, args);
}
va_end(args);
}
void qemu_error_internal(const char *file, int linenr, const char *func,
const char *fmt, ...)
{
va_list va;
QError *qerror;
va_start(va, fmt);
qerror = qerror_from_info(file, linenr, func, fmt, &va);
va_end(va);
if (cur_mon) {
monitor_set_error(cur_mon, qerror);
} else {
qerror_print(qerror);
QDECREF(qerror);
}
}