diff mbox

[v2,4/7] virtio: Use aio_set_event_notifier for aio vq

Message ID 20160624123934.10821-5-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng June 24, 2016, 12:39 p.m. UTC
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 hw/virtio/virtio.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Stefan Hajnoczi June 28, 2016, 3:09 p.m. UTC | #1
On Fri, Jun 24, 2016 at 08:39:31PM +0800, Fam Zheng wrote:

Commit description?  For example:

Distinguish between virtqueue processing in the iohandler context and
main loop AioContext.  iohandler context is isolated from AioContexts
and therefore does not run during aio_poll().
diff mbox

Patch

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 1ea6f66..a586529 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1835,11 +1835,21 @@  static void virtio_queue_host_notifier_read(EventNotifier *n)
 void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
                                                bool set_handler)
 {
+    AioContext *ctx = qemu_get_aio_context();
     if (assign && set_handler) {
-        event_notifier_set_handler(&vq->host_notifier, true,
+        if (vq->use_aio) {
+            aio_set_event_notifier(ctx, &vq->host_notifier, true,
                                    virtio_queue_host_notifier_read);
+        } else {
+            event_notifier_set_handler(&vq->host_notifier, true,
+                                       virtio_queue_host_notifier_read);
+        }
     } else {
-        event_notifier_set_handler(&vq->host_notifier, true, NULL);
+        if (vq->use_aio) {
+            aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL);
+        } else {
+            event_notifier_set_handler(&vq->host_notifier, true, NULL);
+        }
     }
     if (!assign) {
         /* Test and clear notifier before after disabling event,