diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2016-10-24 18:31:02 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-11-01 16:06:57 +0100 |
| commit | 397d30e9401d2da96dbdf0ce49805d6d4bb68833 (patch) | |
| tree | ddf7d8155ff00678ab56f7b00aa33e136a649d64 /monitor.c | |
| parent | 9bc9732faeff09828fe38c0ebe2401ee131a6fca (diff) | |
| download | focaccia-qemu-397d30e9401d2da96dbdf0ce49805d6d4bb68833.tar.gz focaccia-qemu-397d30e9401d2da96dbdf0ce49805d6d4bb68833.zip | |
qemu-error: remove dependency of stubs on monitor
Leave the implementation of error_vprintf and error_vprintf_unless_qmp (the latter now trivially wrapped by error_printf_unless_qmp) to libqemustub.a and monitor.c. This has two advantages: it lets us remove the monitor_printf and monitor_vprintf stubs, and it lets tests provide a different implementation of the functions that uses g_test_message. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1477326663-67817-2-git-send-email-pbonzini@redhat.com>
Diffstat (limited to 'monitor.c')
| -rw-r--r-- | monitor.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c index 7b963ad1ad..0841d436b0 100644 --- a/monitor.c +++ b/monitor.c @@ -3955,6 +3955,27 @@ static void monitor_readline_flush(void *opaque) monitor_flush(opaque); } +/* + * Print to current monitor if we have one, else to stderr. + * TODO should return int, so callers can calculate width, but that + * requires surgery to monitor_vprintf(). Left for another day. + */ +void error_vprintf(const char *fmt, va_list ap) +{ + if (cur_mon && !monitor_cur_is_qmp()) { + monitor_vprintf(cur_mon, fmt, ap); + } else { + vfprintf(stderr, fmt, ap); + } +} + +void error_vprintf_unless_qmp(const char *fmt, va_list ap) +{ + if (cur_mon && !monitor_cur_is_qmp()) { + monitor_vprintf(cur_mon, fmt, ap); + } +} + static void __attribute__((constructor)) monitor_lock_init(void) { qemu_mutex_init(&monitor_lock); |