summaryrefslogtreecommitdiff
path: root/iohandler.c
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2012-07-18 22:52:04 +1000
committerAnthony Liguori <aliguori@us.ibm.com>2012-08-21 15:16:29 -0500
commit55ce75faf253d4369670f60409c608e665e8dde9 (patch)
treee809e4f17e0930d5df2c987f420dabe2732383c7 /iohandler.c
parent682527c00409d676c0d3b9fac99ca3b2fdfd6d2c (diff)
downloadqemu-55ce75faf253d4369670f60409c608e665e8dde9.tar.gz
qemu-55ce75faf253d4369670f60409c608e665e8dde9.tar.bz2
qemu-55ce75faf253d4369670f60409c608e665e8dde9.zip
eventfd: making it thread safe
QEMU uses IO handlers to run select() in the main loop. The handlers list is managed by qemu_set_fd_handler() helper which works fine when called from the main thread as it is called when select() is not waiting. However IO handlers list can be changed in the thread other than the main one doing os_host_main_loop_wait(), for example, as a result of a hypercall which changes PCI config space (VFIO on POWER is the case) and enables/disabled MSI/MSIX which closes/creates eventfd handles. As the main loop should be waiting on the newly created eventfds, it has to be restarted. The patch adds the qemu_notify_event() call to interrupt select() to make main_loop() restart select() with the updated IO handlers list. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'iohandler.c')
-rw-r--r--iohandler.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/iohandler.c b/iohandler.c
index 3c74de612b..dea43552d2 100644
--- a/iohandler.c
+++ b/iohandler.c
@@ -77,6 +77,7 @@ int qemu_set_fd_handler2(int fd,
ioh->fd_write = fd_write;
ioh->opaque = opaque;
ioh->deleted = 0;
+ qemu_notify_event();
}
return 0;
}