From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org
Subject: [Qemu-devel] [PULL 14/15] virtio: merge virtio_queue_aio_set_host_notifier_handler with virtio_queue_set_aio
Date: Fri, 8 Apr 2016 11:02:52 +0300 [thread overview]
Message-ID: <1460102154-16096-15-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1460102154-16096-1-git-send-email-mst@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
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>
---
include/hw/virtio/virtio.h | 6 ++----
hw/block/dataplane/virtio-blk.c | 7 +++----
hw/scsi/virtio-scsi-dataplane.c | 12 ++++--------
hw/virtio/virtio.c | 17 +++++------------
4 files changed, 14 insertions(+), 28 deletions(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index fa3f93b..6a37065 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -142,9 +142,6 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
void (*handle_output)(VirtIODevice *,
VirtQueue *));
-void virtio_set_queue_aio(VirtQueue *vq,
- void (*handle_output)(VirtIODevice *, VirtQueue *));
-
void virtio_del_queue(VirtIODevice *vdev, int n);
void *virtqueue_alloc_element(size_t sz, unsigned out_num, unsigned in_num);
@@ -254,7 +251,8 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
bool set_handler);
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
- bool assign, bool set_handler);
+ void (*fn)(VirtIODevice *,
+ VirtQueue *));
void virtio_irq(VirtQueue *vq);
VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 65c7f70..3cb97c9 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -237,8 +237,8 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
/* Get this show started by hooking up our callbacks */
aio_context_acquire(s->ctx);
- virtio_set_queue_aio(s->vq, virtio_blk_data_plane_handle_output);
- virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx, true, true);
+ virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx,
+ virtio_blk_data_plane_handle_output);
aio_context_release(s->ctx);
return;
@@ -273,8 +273,7 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
aio_context_acquire(s->ctx);
/* Stop notifications for new requests from guest */
- virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx, false, false);
- virtio_set_queue_aio(s->vq, NULL);
+ virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx, NULL);
/* Drain and switch bs back to the QEMU main loop */
blk_set_aio_context(s->conf->conf.blk, qemu_get_aio_context());
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 39ad086..1a49f1e 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -81,8 +81,7 @@ static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,
return rc;
}
- virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, true, true);
- virtio_set_queue_aio(vq, fn);
+ virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, fn);
return 0;
}
@@ -99,13 +98,10 @@ static void virtio_scsi_clear_aio(VirtIOSCSI *s)
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
int i;
- virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, false, false);
- virtio_set_queue_aio(vs->ctrl_vq, NULL);
- virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx, false, false);
- virtio_set_queue_aio(vs->event_vq, NULL);
+ virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, NULL);
+ virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx, NULL);
for (i = 0; i < vs->conf.num_queues; i++) {
- virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx, false, false);
- virtio_set_queue_aio(vs->cmd_vqs[i], NULL);
+ virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx, NULL);
}
}
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index eb04ac0..f745c4a 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;
}
}
--
MST
next prev parent reply other threads:[~2016-04-08 8:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 8:02 [Qemu-devel] [PULL 00/15] pci, virtio, acpi: fixes for 2.6 Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 01/15] acpi: Add missing GCC_FMT_ATTR Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 02/15] pci-testdev: fast mmio support Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 03/15] xen: piix reuse pci generic class init function Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 04/15] Sort the fw_cfg file list Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 05/15] Migration: Add i82801b11 migration data Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 06/15] virtio-balloon: reset the statistic timer to load device Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 07/15] tests/bios-tables-test: fix assert Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 08/15] virtio: make virtio_queue_notify_vq static Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 09/15] virtio-blk: fix disabled mode Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 10/15] virtio-scsi: " Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 11/15] virtio: add aio handler Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 12/15] virtio-blk: use aio handler for data plane Michael S. Tsirkin
2016-04-08 8:02 ` [Qemu-devel] [PULL 13/15] virtio-scsi: " Michael S. Tsirkin
2016-04-08 8:02 ` Michael S. Tsirkin [this message]
2016-04-08 8:02 ` [Qemu-devel] [PULL 15/15] hw/pci-bridge: Add missing unref in case register-bus fails Michael S. Tsirkin
2016-04-08 12:45 ` [Qemu-devel] [PULL 00/15] pci, virtio, acpi: fixes for 2.6 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460102154-16096-15-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=cornelia.huck@de.ibm.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).