Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20200601a' into...
[qemu/ar7.git] / util / qemu-print.c
blobe79d6b839696ee27af4f5e5479ab6eea6520a12f
1 /*
2 * Print to stream or current monitor
4 * Copyright (C) 2019 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 "qemu/osdep.h"
14 #include "monitor/monitor.h"
15 #include "qemu/qemu-print.h"
18 * Print like vprintf().
19 * Print to current monitor if we have one, else to stdout.
21 int qemu_vprintf(const char *fmt, va_list ap)
23 if (cur_mon) {
24 return monitor_vprintf(cur_mon, fmt, ap);
26 return vprintf(fmt, ap);
30 * Print like printf().
31 * Print to current monitor if we have one, else to stdout.
33 int qemu_printf(const char *fmt, ...)
35 va_list ap;
36 int ret;
38 va_start(ap, fmt);
39 ret = qemu_vprintf(fmt, ap);
40 va_end(ap);
41 return ret;
45 * Print like vfprintf()
46 * Print to @stream if non-null, else to current monitor.
48 int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
50 if (!stream) {
51 return monitor_vprintf(cur_mon, fmt, ap);
53 return vfprintf(stream, fmt, ap);
57 * Print like fprintf().
58 * Print to @stream if non-null, else to current monitor.
60 int qemu_fprintf(FILE *stream, const char *fmt, ...)
62 va_list ap;
63 int ret;
65 va_start(ap, fmt);
66 ret = qemu_vfprintf(stream, fmt, ap);
67 va_end(ap);
68 return ret;