diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2016-12-01 19:26:43 +0000 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-01-03 16:38:48 +0000 |
commit | 0062ea0fd601c21f5c7b0d9bd1147fe216010c31 (patch) | |
tree | 302f6fa72006c818a4752556ad2485f825b729aa /hw | |
parent | 4a1cba3802554a3b077d436002519ff1fb0c18bf (diff) | |
download | qemu-0062ea0fd601c21f5c7b0d9bd1147fe216010c31.zip |
virtio: poll virtqueues for new buffers
Add an AioContext poll handler to detect new virtqueue buffers without
waiting for a guest->host notification.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20161201192652.9509-5-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/virtio/virtio.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6f8ca253d9..38704111be 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -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, |