xref: /openbmc/qemu/util/qemu-print.c (revision ba4912cb0d6035192d58fbb4b901e8f39cfd0948)
1 /*
2  * Print to stream or current monitor
3  *
4  * Copyright (C) 2019 Red Hat Inc.
5  *
6  * Authors:
7  *  Markus Armbruster <armbru@redhat.com>,
8  *
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.
11  */
12 
13 #include "qemu/osdep.h"
14 #include "monitor/monitor.h"
15 #include "qemu/qemu-print.h"
16 
17 /*
18  * Print like vprintf().
19  * Print to current monitor if we have one, else to stdout.
20  */
21 int qemu_vprintf(const char *fmt, va_list ap)
22 {
23     if (cur_mon) {
24         return monitor_vprintf(cur_mon, fmt, ap);
25     }
26     return vprintf(fmt, ap);
27 }
28 
29 /*
30  * Print like printf().
31  * Print to current monitor if we have one, else to stdout.
32  */
33 int qemu_printf(const char *fmt, ...)
34 {
35     va_list ap;
36     int ret;
37 
38     va_start(ap, fmt);
39     ret = qemu_vprintf(fmt, ap);
40     va_end(ap);
41     return ret;
42 }
43