aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2020-10-05 17:58:44 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-10-09 07:08:19 +0200
commit947e47448dcc4e4d7a8b7c42b43acb3435b3ad35 (patch)
tree855a18a7da785ee7dff7919ec9a02be34c6ff51c /util
parent87e6f4a4d6885006931b371771e2933c40700427 (diff)
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 <kwolf@redhat.com> Message-Id: <20201005155855.256490-4-kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/qemu-error.c6
-rw-r--r--util/qemu-print.c3
-rw-r--r--util/qemu-sockets.c1
3 files changed, 6 insertions, 4 deletions
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");