]> git.proxmox.com Git - qemu.git/commitdiff
event_notifier: add event_notifier_set
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 5 Jul 2012 15:16:22 +0000 (17:16 +0200)
committerAvi Kivity <avi@redhat.com>
Thu, 12 Jul 2012 11:05:46 +0000 (14:05 +0300)
EventNotifier right now cannot be used as an inter-thread communication
primitive.  It only works if something else (the kernel) sets the eventfd.
Add a primitive to signal an EventNotifier that another thread is waiting
on.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
event_notifier.c
event_notifier.h

index 0b829813d38bf6b5ece73e53a41961c12588b12f..2b210f4b44f4de254239c5010ca6f1217ee2a3ef 100644 (file)
@@ -38,6 +38,13 @@ int event_notifier_get_fd(EventNotifier *e)
     return e->fd;
 }
 
+int event_notifier_set(EventNotifier *e)
+{
+    uint64_t value = 1;
+    int r = write(e->fd, &value, sizeof(value));
+    return r == sizeof(value);
+}
+
 int event_notifier_test_and_clear(EventNotifier *e)
 {
     uint64_t value;
index 886222cb36a8cf59e08faf16cc758f422f0fbcb1..efca852d102209caea828d210a4f49c5e7a272cf 100644 (file)
@@ -22,6 +22,7 @@ struct EventNotifier {
 int event_notifier_init(EventNotifier *, int active);
 void event_notifier_cleanup(EventNotifier *);
 int event_notifier_get_fd(EventNotifier *);
+int event_notifier_set(EventNotifier *);
 int event_notifier_test_and_clear(EventNotifier *);
 int event_notifier_test(EventNotifier *);