]> git.proxmox.com Git - qemu.git/commitdiff
eventfd: making it thread safe
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Wed, 18 Jul 2012 12:52:04 +0000 (22:52 +1000)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 21 Aug 2012 20:16:29 +0000 (15:16 -0500)
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>
iohandler.c

index 3c74de612b2c647b47b081f57d959e896da08e85..dea43552d2a37fd4d52cd58a8332694aeaf98d9f 100644 (file)
@@ -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;
 }