@@ -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);
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> --- hw/virtio/virtio.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)