[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/4] monitor: set the chardev context from the main
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 3/4] monitor: set the chardev context from the main context/thread |
Date: |
Wed, 20 Feb 2019 17:06:27 +0100 |
With the previous changes to qemu_chr_fe_set_handlers(), it is no
longer necessary to call qemu_chr_fe_set_handlers() from the target
context.
Signed-off-by: Marc-André Lureau <address@hidden>
---
monitor.c | 39 ++++++---------------------------------
1 file changed, 6 insertions(+), 33 deletions(-)
diff --git a/monitor.c b/monitor.c
index 33ccbf3957..2312573300 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4513,19 +4513,6 @@ static void monitor_list_append(Monitor *mon)
}
}
-static void monitor_qmp_setup_handlers_bh(void *opaque)
-{
- Monitor *mon = opaque;
- GMainContext *context;
-
- assert(mon->use_io_thread);
- context = iothread_get_g_main_context(mon_iothread);
- assert(context);
- qemu_chr_fe_set_handlers(&mon->chr, monitor_can_read, monitor_qmp_read,
- monitor_qmp_event, NULL, mon, context, true);
- monitor_list_append(mon);
-}
-
void monitor_init(Chardev *chr, int flags)
{
Monitor *mon = g_malloc(sizeof(*mon));
@@ -4548,29 +4535,15 @@ void monitor_init(Chardev *chr, int flags)
}
if (monitor_is_qmp(mon)) {
+ GMainContext *ctxt = mon->use_io_thread ?
+ iothread_get_g_main_context(mon_iothread) : NULL;
+
qemu_chr_fe_set_echo(&mon->chr, true);
json_message_parser_init(&mon->qmp.parser, handle_qmp_command,
mon, NULL);
- if (mon->use_io_thread) {
- /*
- * Make sure the old iowatch is gone. It's possible when
- * e.g. the chardev is in client mode, with wait=on.
- */
- remove_fd_in_watch(chr);
- /*
- * We can't call qemu_chr_fe_set_handlers() directly here
- * since chardev might be running in the monitor I/O
- * thread. Schedule a bottom half.
- */
- aio_bh_schedule_oneshot(iothread_get_aio_context(mon_iothread),
- monitor_qmp_setup_handlers_bh, mon);
- /* The bottom half will add @mon to @mon_list */
- return;
- } else {
- qemu_chr_fe_set_handlers(&mon->chr, monitor_can_read,
- monitor_qmp_read, monitor_qmp_event,
- NULL, mon, NULL, true);
- }
+ qemu_chr_fe_set_handlers(&mon->chr, monitor_can_read,
+ monitor_qmp_read, monitor_qmp_event,
+ NULL, mon, ctxt, true);
} else {
qemu_chr_fe_set_handlers(&mon->chr, monitor_can_read, monitor_read,
monitor_event, NULL, mon, NULL, true);
--
2.21.0.rc1
[Qemu-devel] [PATCH 3/4] monitor: set the chardev context from the main context/thread,
Marc-André Lureau <=
[Qemu-devel] [PATCH 4/4] char-socket: restart the reconnect timer to switch context, Marc-André Lureau, 2019/02/20
Re: [Qemu-devel] [PATCH 0/4] RFC: make chardev context switching safer, Peter Xu, 2019/02/21