mirror of
https://github.com/qemu/qemu.git
synced 2025-01-19 12:03:51 +08:00
main-loop: fix qemu_notify_event for aio_notify optimization
aio_notify can be optimized away, and in fact almost always will. However, qemu_notify_event is used in places where this is incorrect---most notably, when handling SIGTERM. When aio_notify is optimized away, it is possible that QEMU enters a blocking ppoll immediately afterwards and stays there, without reaching main_loop_should_exit(). Fix this by using a bottom half. The bottom half can be optimized too, but scheduling it is enough for the ppoll not to block. The hang is thus avoided. Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1437738175-23624-1-git-send-email-pbonzini@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
3737129917
commit
edec47cfef
11
main-loop.c
11
main-loop.c
@ -114,6 +114,14 @@ static int qemu_signal_init(void)
|
||||
#endif
|
||||
|
||||
static AioContext *qemu_aio_context;
|
||||
static QEMUBH *qemu_notify_bh;
|
||||
|
||||
static void notify_event_cb(void *opaque)
|
||||
{
|
||||
/* No need to do anything; this bottom half is only used to
|
||||
* kick the kernel out of ppoll/poll/WaitForMultipleObjects.
|
||||
*/
|
||||
}
|
||||
|
||||
AioContext *qemu_get_aio_context(void)
|
||||
{
|
||||
@ -125,7 +133,7 @@ void qemu_notify_event(void)
|
||||
if (!qemu_aio_context) {
|
||||
return;
|
||||
}
|
||||
aio_notify(qemu_aio_context);
|
||||
qemu_bh_schedule(qemu_notify_bh);
|
||||
}
|
||||
|
||||
static GArray *gpollfds;
|
||||
@ -144,6 +152,7 @@ int qemu_init_main_loop(Error **errp)
|
||||
}
|
||||
|
||||
qemu_aio_context = aio_context_new(&local_error);
|
||||
qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
|
||||
if (!qemu_aio_context) {
|
||||
error_propagate(errp, local_error);
|
||||
return -EMFILE;
|
||||
|
Loading…
Reference in New Issue
Block a user