提交 ef12a703 编写于 作者: M Marc-André Lureau 提交者: Markus Armbruster

monitor: accept chardev input from iothread

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 >
9005b2a7). 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: NMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: NPeter Xu <peterx@redhat.com>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
Message-Id: <20181205203737.9011-3-marcandre.lureau@redhat.com>
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
上级 88e40e43
...@@ -4297,7 +4297,7 @@ int monitor_suspend(Monitor *mon) ...@@ -4297,7 +4297,7 @@ int monitor_suspend(Monitor *mon)
atomic_inc(&mon->suspend_cnt); 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 * Kick I/O thread to make sure this takes effect. It'll be
* evaluated again in prepare() of the watch object. * evaluated again in prepare() of the watch object.
...@@ -4309,6 +4309,13 @@ int monitor_suspend(Monitor *mon) ...@@ -4309,6 +4309,13 @@ int monitor_suspend(Monitor *mon)
return 0; return 0;
} }
static void monitor_accept_input(void *opaque)
{
Monitor *mon = opaque;
qemu_chr_fe_accept_input(&mon->chr);
}
void monitor_resume(Monitor *mon) void monitor_resume(Monitor *mon)
{ {
if (monitor_is_hmp_non_interactive(mon)) { if (monitor_is_hmp_non_interactive(mon)) {
...@@ -4316,20 +4323,22 @@ void monitor_resume(Monitor *mon) ...@@ -4316,20 +4323,22 @@ void monitor_resume(Monitor *mon)
} }
if (atomic_dec_fetch(&mon->suspend_cnt) == 0) { if (atomic_dec_fetch(&mon->suspend_cnt) == 0) {
if (monitor_is_qmp(mon)) { AioContext *ctx;
/*
* For QMP monitors that are running in the I/O thread, if (mon->use_io_thread) {
* let's kick the thread in case it's sleeping. ctx = iothread_get_aio_context(mon_iothread);
*/
if (mon->use_io_thread) {
aio_notify(iothread_get_aio_context(mon_iothread));
}
} else { } else {
ctx = qemu_get_aio_context();
}
if (!monitor_is_qmp(mon)) {
assert(mon->rs); assert(mon->rs);
readline_show_prompt(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); trace_monitor_suspend(mon, -1);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册