[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/11] monitor: accept chardev input from iothread
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 02/11] monitor: accept chardev input from iothread |
Date: |
Wed, 12 Dec 2018 11:11:36 +0100 |
From: Marc-André Lureau <address@hidden>
Chardev backends may not handle safely IO events from concurrent
threads (may not handle I/O events from concurrent threads safely,
only the write path is since commit >
9005b2a7589540a3733b3abdcfbccfe7746cd1a1). Better to wake up the
chardev from the monitor IO thread if it's being used as the chardev
context.
Unify code paths by using a BH in all cases.
Drop the now redundant aio_notify() call.
Clean up control flow not to rely on mon->use_io_thread implying
monitor_is_qmp(mon).
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Peter Xu <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
---
monitor.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/monitor.c b/monitor.c
index d531e8ccc9..79afe99079 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4297,7 +4297,7 @@ int monitor_suspend(Monitor *mon)
atomic_inc(&mon->suspend_cnt);
- if (monitor_is_qmp(mon) && mon->use_io_thread) {
+ if (mon->use_io_thread) {
/*
* Kick I/O thread to make sure this takes effect. It'll be
* evaluated again in prepare() of the watch object.
@@ -4309,6 +4309,13 @@ int monitor_suspend(Monitor *mon)
return 0;
}
+static void monitor_accept_input(void *opaque)
+{
+ Monitor *mon = opaque;
+
+ qemu_chr_fe_accept_input(&mon->chr);
+}
+
void monitor_resume(Monitor *mon)
{
if (monitor_is_hmp_non_interactive(mon)) {
@@ -4316,20 +4323,22 @@ void monitor_resume(Monitor *mon)
}
if (atomic_dec_fetch(&mon->suspend_cnt) == 0) {
- if (monitor_is_qmp(mon)) {
- /*
- * For QMP monitors that are running in the I/O thread,
- * let's kick the thread in case it's sleeping.
- */
- if (mon->use_io_thread) {
- aio_notify(iothread_get_aio_context(mon_iothread));
- }
+ AioContext *ctx;
+
+ if (mon->use_io_thread) {
+ ctx = iothread_get_aio_context(mon_iothread);
} else {
+ ctx = qemu_get_aio_context();
+ }
+
+ if (!monitor_is_qmp(mon)) {
assert(mon->rs);
readline_show_prompt(mon->rs);
}
- qemu_chr_fe_accept_input(&mon->chr);
+
+ aio_bh_schedule_oneshot(ctx, monitor_accept_input, mon);
}
+
trace_monitor_suspend(mon, -1);
}
--
2.17.2
- [Qemu-devel] [PULL 00/11] Monitor patches for 2018-12-12, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 02/11] monitor: accept chardev input from iothread,
Markus Armbruster <=
- [Qemu-devel] [PULL 06/11] monitor: prevent inserting new monitors after cleanup, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 04/11] monitor: check if chardev can switch gcontext for OOB, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 05/11] colo: check chardev can switch context, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 03/11] char: add a QEMU_CHAR_FEATURE_GCONTEXT flag, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 01/11] monitor: inline ambiguous helper functions, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 10/11] Revert "tests: Add parameter to qtest_init_without_qmp_handshake", Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 08/11] monitor: Suspend monitor instead dropping commands, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 07/11] monitor: avoid potential dead-lock when cleaning up, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 11/11] tests: add oob functional test for test-qmp-cmds, Markus Armbruster, 2018/12/12
- [Qemu-devel] [PULL 09/11] monitor: Remove "x-oob", offer capability "oob" unconditionally, Markus Armbruster, 2018/12/12