From 947e47448dcc4e4d7a8b7c42b43acb3435b3ad35 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 5 Oct 2020 17:58:44 +0200 Subject: monitor: Use getter/setter functions for cur_mon cur_mon really needs to be coroutine-local as soon as we move monitor command handlers to coroutines and let them yield. As a first step, just remove all direct accesses to cur_mon so that we can implement this in the getter function later. Signed-off-by: Kevin Wolf Message-Id: <20201005155855.256490-4-kwolf@redhat.com> Reviewed-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Signed-off-by: Markus Armbruster --- util/qemu-error.c | 6 +++--- util/qemu-print.c | 3 ++- util/qemu-sockets.c | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'util') diff --git a/util/qemu-error.c b/util/qemu-error.c index 3ee41438e9..aa30f03564 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -171,7 +171,7 @@ static void print_loc(void) int i; const char *const *argp; - if (!cur_mon && progname) { + if (!monitor_cur() && progname) { fprintf(stderr, "%s:", progname); sep = " "; } @@ -208,7 +208,7 @@ static void vreport(report_type type, const char *fmt, va_list ap) GTimeVal tv; gchar *timestr; - if (error_with_timestamp && !cur_mon) { + if (error_with_timestamp && !monitor_cur()) { g_get_current_time(&tv); timestr = g_time_val_to_iso8601(&tv); error_printf("%s ", timestr); @@ -216,7 +216,7 @@ static void vreport(report_type type, const char *fmt, va_list ap) } /* Only prepend guest name if -msg guest-name and -name guest=... are set */ - if (error_with_guestname && error_guest_name && !cur_mon) { + if (error_with_guestname && error_guest_name && !monitor_cur()) { error_printf("%s ", error_guest_name); } diff --git a/util/qemu-print.c b/util/qemu-print.c index e79d6b8396..69ba612f56 100644 --- a/util/qemu-print.c +++ b/util/qemu-print.c @@ -20,6 +20,7 @@ */ int qemu_vprintf(const char *fmt, va_list ap) { + Monitor *cur_mon = monitor_cur(); if (cur_mon) { return monitor_vprintf(cur_mon, fmt, ap); } @@ -48,7 +49,7 @@ int qemu_printf(const char *fmt, ...) int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap) { if (!stream) { - return monitor_vprintf(cur_mon, fmt, ap); + return monitor_vprintf(monitor_cur(), fmt, ap); } return vfprintf(stream, fmt, ap); } diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index de4bf7616e..05e5c73f9d 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1092,6 +1092,7 @@ fail: static int socket_get_fd(const char *fdstr, int num, Error **errp) { + Monitor *cur_mon = monitor_cur(); int fd; if (num != 1) { error_setg_errno(errp, EINVAL, "socket_get_fd: too many connections"); -- cgit v1.2.3-70-g09d2