error: Replace qemu_error() by error_report()
[qemu.git] / qemu-error.c
blob51e2abf63668b83fb1ff3685e54d7bc4f113c3a7
1 /*
2 * Error reporting
4 * Copyright (C) 2010 Red Hat Inc.
6 * Authors:
7 * Markus Armbruster <armbru@redhat.com>,
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include <stdio.h>
14 #include "monitor.h"
15 #include "sysemu.h"
18 * Print to current monitor if we have one, else to stderr.
19 * TODO should return int, so callers can calculate width, but that
20 * requires surgery to monitor_vprintf(). Left for another day.
22 void error_vprintf(const char *fmt, va_list ap)
24 if (cur_mon) {
25 monitor_vprintf(cur_mon, fmt, ap);
26 } else {
27 vfprintf(stderr, fmt, ap);
32 * Print to current monitor if we have one, else to stderr.
33 * TODO just like error_vprintf()
35 void error_printf(const char *fmt, ...)
37 va_list ap;
39 va_start(ap, fmt);
40 error_vprintf(fmt, ap);
41 va_end(ap);
45 * Print an error message to current monitor if we have one, else to stderr.
46 * Appends a newline to the message.
47 * It's wrong to call this in a QMP monitor. Use qemu_error_new() there.
49 void error_report(const char *fmt, ...)
51 va_list ap;
53 va_start(ap, fmt);
54 error_vprintf(fmt, ap);
55 va_end(ap);
56 error_printf("\n");
59 void qemu_error_internal(const char *file, int linenr, const char *func,
60 const char *fmt, ...)
62 va_list va;
63 QError *qerror;
65 va_start(va, fmt);
66 qerror = qerror_from_info(file, linenr, func, fmt, &va);
67 va_end(va);
69 if (cur_mon) {
70 monitor_set_error(cur_mon, qerror);
71 } else {
72 qerror_print(qerror);
73 QDECREF(qerror);