Patchwork [4/9] event poll: pass event type to event callback

login
register
mail settings
Submitter pingfan liu
Date Feb. 21, 2013, 12:54 p.m.
Message ID <1361451293-5181-5-git-send-email-qemulist@gmail.com>
Download mbox | patch
Permalink /patch/222278/
State New
Headers show

Comments

pingfan liu - Feb. 21, 2013, 12:54 p.m.
From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>

With this extra arg -- event type, we can support the standard
events dispatched by epoll_wait()

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 hw/dataplane/event-poll.c |    4 ++--
 hw/dataplane/event-poll.h |    2 +-
 hw/dataplane/virtio-blk.c |    6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

Patch

diff --git a/hw/dataplane/event-poll.c b/hw/dataplane/event-poll.c
index b7dea53..e19f3f3 100644
--- a/hw/dataplane/event-poll.c
+++ b/hw/dataplane/event-poll.c
@@ -69,7 +69,7 @@  void event_poll_modify_fd(EventPoll *poll, int fd, uint32_t type,
 }
 
 /* Event callback for stopping event_poll() */
-static void handle_stop(EventHandler *handler)
+static void handle_stop(EventHandler *handler, uint32_t events)
 {
     /* Do nothing */
 }
@@ -123,7 +123,7 @@  void event_poll(EventPoll *poll)
     event_notifier_test_and_clear(handler->notifier);
 
     /* Handle the event */
-    handler->callback(handler);
+    handler->callback(handler, event.events);
 }
 
 /* Stop event_poll()
diff --git a/hw/dataplane/event-poll.h b/hw/dataplane/event-poll.h
index 606138c..ff9712b 100644
--- a/hw/dataplane/event-poll.h
+++ b/hw/dataplane/event-poll.h
@@ -18,7 +18,7 @@ 
 #include "qemu/event_notifier.h"
 
 typedef struct EventHandler EventHandler;
-typedef void EventCallback(EventHandler *handler);
+typedef void EventCallback(EventHandler *handler, uint32_t events);
 struct EventHandler {
     EventNotifier *notifier;        /* eventfd */
     EventCallback *callback;        /* callback function */
diff --git a/hw/dataplane/virtio-blk.c b/hw/dataplane/virtio-blk.c
index 4c4ad84..b60211a 100644
--- a/hw/dataplane/virtio-blk.c
+++ b/hw/dataplane/virtio-blk.c
@@ -206,7 +206,7 @@  static int process_request(IOQueue *ioq, struct iovec iov[],
     return 0;
 }
 
-static void handle_notify(EventHandler *handler)
+static void handle_notify(EventHandler *handler, uint32_t type)
 {
     VirtIOBlockDataPlane *s = container_of(handler, VirtIOBlockDataPlane,
                                            notify_handler);
@@ -284,7 +284,7 @@  static void handle_notify(EventHandler *handler)
     }
 }
 
-static void handle_io(EventHandler *handler)
+static void handle_io(EventHandler *handler, uint32_t type)
 {
     VirtIOBlockDataPlane *s = container_of(handler, VirtIOBlockDataPlane,
                                            io_handler);
@@ -298,7 +298,7 @@  static void handle_io(EventHandler *handler)
      * requests.
      */
     if (unlikely(vring_more_avail(&s->vring))) {
-        handle_notify(&s->notify_handler);
+        handle_notify(&s->notify_handler, type);
     }
 }