From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PATCH 3/3] dataplane/virtio-scsi: new API to enable host notifiers
Date: Tue, 7 Apr 2015 12:46:01 +0200 [thread overview]
Message-ID: <1428403546-31914-4-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1428403546-31914-1-git-send-email-mst@redhat.com>
Switch to new API.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/virtio.h | 1 -
hw/scsi/virtio-scsi-dataplane.c | 14 ++++----------
hw/virtio/virtio.c | 8 +++++++-
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index e1cff22..7e70193 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -217,7 +217,6 @@ 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_notify_vq(VirtQueue *vq);
-void virtio_irq(VirtQueue *vq);
int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs);
void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs);
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 5575648..965ccb8 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -43,13 +43,11 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
EventNotifierHandler *handler,
int n)
{
- BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
- VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSIVring *r;
int rc;
/* Set up virtqueue notify */
- rc = k->set_host_notifier(qbus->parent, n, true);
+ rc = virtio_enable_host_notifiers(VIRTIO_DEVICE(s), n, 1);
if (rc != 0) {
fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
rc);
@@ -72,7 +70,7 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
fail_vring:
aio_set_event_notifier(s->ctx, &r->host_notifier, NULL);
- k->set_host_notifier(qbus->parent, n, false);
+ virtio_disable_host_notifiers(VIRTIO_DEVICE(s), n, 1);
g_slice_free(VirtIOSCSIVring, r);
return NULL;
}
@@ -261,9 +259,7 @@ fail_vrings:
virtio_scsi_clear_aio(s);
aio_context_release(s->ctx);
virtio_scsi_vring_teardown(s);
- for (i = 0; i < vs->conf.num_queues + 2; i++) {
- k->set_host_notifier(qbus->parent, i, false);
- }
+ virtio_disable_host_notifiers(VIRTIO_DEVICE(s), 0, vs->conf.num_queues + 2);
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
fail_guest_notifiers:
s->dataplane_starting = false;
@@ -305,9 +301,7 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
*/
virtio_scsi_vring_teardown(s);
- for (i = 0; i < vs->conf.num_queues + 2; i++) {
- k->set_host_notifier(qbus->parent, i, false);
- }
+ virtio_disable_host_notifiers(VIRTIO_DEVICE(s), 0, vs->conf.num_queues + 2);
/* Clean up guest notifier (irq) */
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index e7ee069..60d10cd 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -84,6 +84,9 @@ struct VirtQueue
int inuse;
+ /* Host notifier enabled? */
+ bool host_notifier_enabled;
+
uint16_t vector;
void (*handle_output)(VirtIODevice *vdev, VirtQueue *vq);
VirtIODevice *vdev;
@@ -813,7 +816,7 @@ void virtio_del_queue(VirtIODevice *vdev, int n)
vdev->vq[n].vring.num = 0;
}
-void virtio_irq(VirtQueue *vq)
+static void virtio_irq(VirtQueue *vq)
{
trace_virtio_irq(vq);
vq->vdev->isr |= 0x01;
@@ -1301,11 +1304,13 @@ int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);
goto fail_vq;
}
+ vdev->vq[startvq + i].host_notifier_enabled = true;
}
return 0;
fail_vq:
while (--i >= 0) {
+ vdev->vq[startvq + i].host_notifier_enabled = false;
r = k->set_host_notifier(qbus->parent, startvq + i, false);
if (r < 0) {
fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);
@@ -1325,6 +1330,7 @@ void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
int i, r;
for (i = 0; i < nvqs; ++i) {
+ vdev->vq[startvq + i].host_notifier_enabled = false;
r = k->set_host_notifier(qbus->parent, startvq + i, false);
if (r < 0) {
fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r);
--
MST
next prev parent reply other threads:[~2015-04-07 10:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 10:45 [Qemu-devel] [PATCH 0/3] virtio: host notifier API cleanup Michael S. Tsirkin
2015-04-07 10:45 ` [Qemu-devel] [PATCH 1/3] virtio: interface to enable/disable host notifiers Michael S. Tsirkin
2015-04-07 11:32 ` Cornelia Huck
2015-04-07 10:45 ` [Qemu-devel] [PATCH 2/3] dataplane/virtio-blk.c: new API to enable notifiers Michael S. Tsirkin
2015-04-07 11:35 ` Cornelia Huck
2015-04-07 10:46 ` Michael S. Tsirkin [this message]
2015-04-07 11:41 ` [Qemu-devel] [PATCH 3/3] dataplane/virtio-scsi: new API to enable host notifiers Cornelia Huck
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=1428403546-31914-4-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).