hw/block/nvme: fix assert crash in nvme_subsys_ns
[qemu/rayw.git] / util / qemu-print.c
blob69ba612f564e04ca86afa3a5ea088c4b7b7d1209
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 Monitor *cur_mon = monitor_cur();
24 if (cur_mon) {
25 return monitor_vprintf(cur_mon, fmt, ap);
27 return vprintf(fmt, ap);
31 * Print like printf().
32 * Print to current monitor if we have one, else to stdout.
34 int qemu_printf(const char *fmt, ...)
36 va_list ap;
37 int ret;
39 va_start(ap, fmt);
40 ret = qemu_vprintf(fmt, ap);
41 va_end(ap);
42 return ret;
46 * Print like vfprintf()
47 * Print to @stream if non-null, else to current monitor.
49 int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
51 if (!stream) {
52 return monitor_vprintf(monitor_cur(), fmt, ap);
54 return vfprintf(stream, fmt, ap);
58 * Print like fprintf().
59 * Print to @stream if non-null, else to current monitor.
61 int qemu_fprintf(FILE *stream, const char *fmt, ...)
63 va_list ap;
64 int ret;
66 va_start(ap, fmt);
67 ret = qemu_vfprintf(stream, fmt, ap);
68 va_end(ap);
69 return ret;