From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4WRG-0000Eq-3g for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:13:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4WRF-0000YF-7b for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:13:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4WRF-0000Xz-22 for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:13:29 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 650D832B0C0 for ; Wed, 9 Nov 2016 17:13:28 +0000 (UTC) From: Stefan Hajnoczi Date: Wed, 9 Nov 2016 17:13:21 +0000 Message-Id: <1478711602-12620-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1478711602-12620-1-git-send-email-stefanha@redhat.com> References: <1478711602-12620-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [RFC 2/3] virtio: poll virtqueues for new buffers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: 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 | 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