qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 2/3] virtio: poll virtqueues for new buffers


From: Stefan Hajnoczi
Subject: [Qemu-devel] [RFC 2/3] virtio: poll virtqueues for new buffers
Date: Wed, 9 Nov 2016 17:13:21 +0000

Add an AioContext poll handler to detect new virtqueue buffers without
waiting for a guest->host notification.

Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 hw/virtio/virtio.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index bcbcfe0..b191e01 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2026,15 +2026,34 @@ static void 
virtio_queue_host_notifier_aio_read(EventNotifier *n)
     }
 }
 
+static bool virtio_queue_aio_poll(void *opaque)
+{
+    VirtQueue *vq = opaque;
+
+    return !virtio_queue_empty(vq);
+}
+
+static void virtio_queue_aio_poll_handler(void *opaque)
+{
+    VirtQueue *vq = opaque;
+
+    virtio_queue_notify_aio_vq(vq);
+}
+
 void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
                                                 VirtIOHandleOutput 
handle_output)
 {
     if (handle_output) {
         vq->handle_aio_output = handle_output;
+        aio_set_poll_handler(ctx,
+                             virtio_queue_aio_poll,
+                             virtio_queue_aio_poll_handler,
+                             vq);
         aio_set_event_notifier(ctx, &vq->host_notifier, true,
                                virtio_queue_host_notifier_aio_read);
     } else {
         aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL);
+        aio_set_poll_handler(ctx, virtio_queue_aio_poll, NULL, vq);
         /* Test and clear notifier before after disabling event,
          * in case poll callback didn't have time to run. */
         virtio_queue_host_notifier_aio_read(&vq->host_notifier);
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]