qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Fam Zheng <famz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-block@nongnu.org
Subject: [Qemu-devel] [PULL 30/34] virtio-bus: have callers tolerate new host notifier api
Date: Fri, 24 Jun 2016 08:55:50 +0300	[thread overview]
Message-ID: <20160624085550-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1466747621-4342-1-git-send-email-mst@redhat.com>

From: Cornelia Huck <cornelia.huck@de.ibm.com>

Have vhost and dataplane use the new api for transports that
have been converted.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/block/dataplane/virtio-blk.c | 14 +++++++++++---
 hw/scsi/virtio-scsi-dataplane.c | 20 +++++++++++++++-----
 hw/virtio/vhost.c               | 20 ++++++++++++++++----
 3 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 2073f9a..fdf5fd1 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -79,7 +79,8 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf,
     }
 
     /* Don't try if transport does not support notifiers. */
-    if (!k->set_guest_notifiers || !k->set_host_notifier) {
+    if (!k->set_guest_notifiers ||
+        (!k->set_host_notifier && !k->ioeventfd_started)) {
         error_setg(errp,
                    "device is incompatible with dataplane "
                    "(transport does not support notifiers)");
@@ -157,7 +158,10 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
     s->guest_notifier = virtio_queue_get_guest_notifier(s->vq);
 
     /* Set up virtqueue notify */
-    r = k->set_host_notifier(qbus->parent, 0, true);
+    r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), 0, true);
+    if (r == -ENOSYS) {
+        r = k->set_host_notifier(qbus->parent, 0, true);
+    }
     if (r != 0) {
         fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n", r);
         goto fail_host_notifier;
@@ -193,6 +197,7 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s->vdev)));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
     VirtIOBlock *vblk = VIRTIO_BLK(s->vdev);
+    int r;
 
     if (!vblk->dataplane_started || s->stopping) {
         return;
@@ -217,7 +222,10 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
 
     aio_context_release(s->ctx);
 
-    k->set_host_notifier(qbus->parent, 0, false);
+    r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), 0, false);
+    if (r == -ENOSYS) {
+        k->set_host_notifier(qbus->parent, 0, false);
+    }
 
     /* Clean up guest notifier (irq) */
     k->set_guest_notifiers(qbus->parent, 1, false);
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 1a49f1e..b9a5716 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -31,7 +31,8 @@ void virtio_scsi_set_iothread(VirtIOSCSI *s, IOThread *iothread)
     s->ctx = iothread_get_aio_context(vs->conf.iothread);
 
     /* Don't try if transport does not support notifiers. */
-    if (!k->set_guest_notifiers || !k->set_host_notifier) {
+    if (!k->set_guest_notifiers ||
+        (!k->set_host_notifier && !k->ioeventfd_started)) {
         fprintf(stderr, "virtio-scsi: Failed to set iothread "
                    "(transport does not support notifiers)");
         exit(1);
@@ -73,7 +74,10 @@ static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,
     int rc;
 
     /* Set up virtqueue notify */
-    rc = k->set_host_notifier(qbus->parent, n, true);
+    rc = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), n, true);
+    if (rc == -ENOSYS) {
+        rc = k->set_host_notifier(qbus->parent, n, true);
+    }
     if (rc != 0) {
         fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
                 rc);
@@ -159,7 +163,10 @@ fail_vrings:
     virtio_scsi_clear_aio(s);
     aio_context_release(s->ctx);
     for (i = 0; i < vs->conf.num_queues + 2; i++) {
-        k->set_host_notifier(qbus->parent, i, false);
+        rc = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
+        if (rc == -ENOSYS) {
+            k->set_host_notifier(qbus->parent, i, false);
+        }
     }
     k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
 fail_guest_notifiers:
@@ -174,7 +181,7 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
-    int i;
+    int i, rc;
 
     if (!s->dataplane_started || s->dataplane_stopping) {
         return;
@@ -198,7 +205,10 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
     aio_context_release(s->ctx);
 
     for (i = 0; i < vs->conf.num_queues + 2; i++) {
-        k->set_host_notifier(qbus->parent, i, false);
+        rc = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
+        if (rc == -ENOSYS) {
+            k->set_host_notifier(qbus->parent, i, false);
+        }
     }
 
     /* Clean up guest notifier (irq) */
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 81cc5b0..bce1b6e 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1110,14 +1110,18 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
     VirtioBusState *vbus = VIRTIO_BUS(qbus);
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
     int i, r, e;
-    if (!k->set_host_notifier) {
+    if (!k->set_host_notifier || !k->ioeventfd_started) {
         fprintf(stderr, "binding does not support host notifiers\n");
         r = -ENOSYS;
         goto fail;
     }
 
     for (i = 0; i < hdev->nvqs; ++i) {
-        r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, true);
+        r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i,
+                                         true);
+        if (r == -ENOSYS) {
+            r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, true);
+        }
         if (r < 0) {
             fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);
             goto fail_vq;
@@ -1127,7 +1131,11 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
     return 0;
 fail_vq:
     while (--i >= 0) {
-        e = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);
+        e = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i,
+                                         false);
+        if (e == -ENOSYS) {
+            e = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);
+        }
         if (e < 0) {
             fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);
             fflush(stderr);
@@ -1151,7 +1159,11 @@ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
     int i, r;
 
     for (i = 0; i < hdev->nvqs; ++i) {
-        r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);
+        r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i,
+                                         false);
+        if (r == -ENOSYS) {
+            r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);
+        }
         if (r < 0) {
             fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r);
             fflush(stderr);
-- 
MST

  parent reply	other threads:[~2016-06-24  5:56 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1466747621-4342-1-git-send-email-mst@redhat.com>
2016-06-24  5:54 ` [Qemu-devel] [PULL 01/34] smbios: Move table build tools into an include file Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 02/34] ipmi: Add SMBIOS table entry Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 03/34] acpi: Add IPMI table entries Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 04/34] bios: Add tests for the IPMI ACPI and SMBIOS entries Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 05/34] pc-dimm: introduce get_vmstate_memory_region callback Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 06/34] nvdimm: support nvdimm label Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 07/34] acpi: add aml_object_type Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 08/34] acpi: add aml_call5 Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 09/34] nvdimm acpi: set HDLE properly Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 10/34] nvdimm acpi: save arg3 of _DSM method Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 11/34] nvdimm acpi: check UUID Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 12/34] nvdimm acpi: abstract the operations for root & nvdimm devices Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 13/34] nvdimm acpi: check revision Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 14/34] nvdimm acpi: support Get Namespace Label Size function Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 15/34] nvdimm acpi: support Get Namespace Label Data function Michael S. Tsirkin
2016-06-24  5:54 ` [Qemu-devel] [PULL 16/34] nvdimm acpi: support Set " Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 17/34] docs: add NVDIMM ACPI documentation Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 18/34] i386: pci-assign: Fix MSI-X table size Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 19/34] docs: update ACPI CPU hotplug spec with new protocol Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 20/34] pc: piix4/ich9: add 'cpu-hotplug-legacy' property Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 21/34] acpi: cpuhp: add CPU devices AML with _STA method Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 22/34] pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 23/34] acpi: cpuhp: implement hot-add parts of CPU hotplug interface Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 24/34] acpi: cpuhp: implement hot-remove " Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 25/34] acpi: cpuhp: add cpu._OST handling Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 26/34] pc: use new CPU hotplug interface since 2.7 machine type Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 27/34] acpi-test-data: update expected Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 28/34] pc: acpi: drop intermediate PCMachineState.node_cpu Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 29/34] virtio-bus: common ioeventfd infrastructure Michael S. Tsirkin
2016-06-24  5:55 ` Michael S. Tsirkin [this message]
2016-06-29 11:37   ` [Qemu-devel] [PULL 30/34] virtio-bus: have callers tolerate new host notifier api Marc-André Lureau
2016-06-29 11:48     ` Cornelia Huck
2016-06-24  5:55 ` [Qemu-devel] [PULL 31/34] virtio-ccw: convert to ioeventfd callbacks Michael S. Tsirkin
2016-06-24  5:55 ` [Qemu-devel] [PULL 32/34] virtio-pci: " Michael S. Tsirkin
2016-06-24  5:56 ` [Qemu-devel] [PULL 33/34] virtio-mmio: " Michael S. Tsirkin
2016-06-24  5:56 ` [Qemu-devel] [PULL 34/34] virtio-bus: remove old set_host_notifier callback Michael S. Tsirkin

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=20160624085550-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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).