]> Git Repo - qemu.git/commitdiff
virtio: poll virtqueues for new buffers
authorStefan Hajnoczi <[email protected]>
Thu, 1 Dec 2016 19:26:43 +0000 (19:26 +0000)
committerStefan Hajnoczi <[email protected]>
Tue, 3 Jan 2017 16:38:48 +0000 (16:38 +0000)
Add an AioContext poll handler to detect new virtqueue buffers without
waiting for a guest->host notification.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-id: 20161201192652[email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
hw/virtio/virtio.c

index 6f8ca253d9fcd7f79a9de4f41aa0bbfd931e30bf..38704111be58ec7208799ffac6dca2e1cbaaac08 100644 (file)
@@ -2047,13 +2047,27 @@ static void virtio_queue_host_notifier_aio_read(EventNotifier *n)
     }
 }
 
+static bool virtio_queue_host_notifier_aio_poll(void *opaque)
+{
+    EventNotifier *n = opaque;
+    VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
+
+    if (virtio_queue_empty(vq)) {
+        return false;
+    }
+
+    virtio_queue_notify_aio_vq(vq);
+    return true;
+}
+
 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_event_notifier(ctx, &vq->host_notifier, true,
-                               virtio_queue_host_notifier_aio_read, NULL);
+                               virtio_queue_host_notifier_aio_read,
+                               virtio_queue_host_notifier_aio_poll);
     } else {
         aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL);
         /* Test and clear notifier before after disabling event,
This page took 0.043672 seconds and 4 git commands to generate.