summaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-04-06 12:16:28 +0200
committerMichael S. Tsirkin <mst@redhat.com>2016-04-07 19:57:33 +0300
commita378b49a4338ef61b86f4c74a1069036c7409141 (patch)
tree8a137c4ebf06c2d7cac28179204a4e890c33e5eb /hw/virtio
parenta8f2e5c8fffbaf7fbd4f0efc8efbeebade78008f (diff)
downloadqemu-a378b49a4338ef61b86f4c74a1069036c7409141.tar.gz
virtio: merge virtio_queue_aio_set_host_notifier_handler with virtio_queue_set_aio
Eliminating the reentrancy is actually a nice thing that we can do with the API that Michael proposed, so let's make it first class. This also hides the complex assign/set_handler conventions from callers of virtio_queue_aio_set_host_notifier_handler, which in fact was always called with assign=true. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/virtio.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index eb04ac07eb..f745c4abd0 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1159,14 +1159,6 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
return &vdev->vq[i];
}
-void virtio_set_queue_aio(VirtQueue *vq,
- void (*handle_output)(VirtIODevice *, VirtQueue *))
-{
- assert(vq->handle_output);
-
- vq->handle_aio_output = handle_output;
-}
-
void virtio_del_queue(VirtIODevice *vdev, int n)
{
if (n < 0 || n >= VIRTIO_QUEUE_MAX) {
@@ -1809,18 +1801,19 @@ static void virtio_queue_host_notifier_aio_read(EventNotifier *n)
}
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
- bool assign, bool set_handler)
+ void (*handle_output)(VirtIODevice *,
+ VirtQueue *))
{
- if (assign && set_handler) {
+ if (handle_output) {
+ vq->handle_aio_output = handle_output;
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);
- }
- if (!assign) {
/* 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);
+ vq->handle_aio_output = NULL;
}
}