From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCX0b-0004CU-3n for qemu-devel@nongnu.org; Thu, 01 Dec 2016 14:27:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCX0a-0002Ze-Cz for qemu-devel@nongnu.org; Thu, 01 Dec 2016 14:27:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCX0a-0002ZH-7X for qemu-devel@nongnu.org; Thu, 01 Dec 2016 14:27:04 -0500 From: Stefan Hajnoczi Date: Thu, 1 Dec 2016 19:26:43 +0000 Message-Id: <20161201192652.9509-5-stefanha@redhat.com> In-Reply-To: <20161201192652.9509-1-stefanha@redhat.com> References: <20161201192652.9509-1-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v4 04/13] virtio: poll virtqueues for new buffers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: borntraeger@de.ibm.com, Paolo Bonzini , Karl Rister , Fam Zheng , Stefan Hajnoczi Add an AioContext poll handler to detect new virtqueue buffers without waiting for a guest->host notification. Signed-off-by: Stefan Hajnoczi --- hw/virtio/virtio.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6f8ca25..3870411 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, -- 2.9.3