From patchwork Mon Apr 25 16:57:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 8930711 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E26BEBF29F for ; Mon, 25 Apr 2016 16:59:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19DE020138 for ; Mon, 25 Apr 2016 16:59:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F2BAB2012B for ; Mon, 25 Apr 2016 16:59:21 +0000 (UTC) Received: from localhost ([::1]:32981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aujqz-0002Db-EO for patchwork-qemu-devel@patchwork.kernel.org; Mon, 25 Apr 2016 12:59:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aujpD-00076D-2H for qemu-devel@nongnu.org; Mon, 25 Apr 2016 12:57:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aujp8-0007Kd-Tu for qemu-devel@nongnu.org; Mon, 25 Apr 2016 12:57:30 -0400 Received: from e06smtp08.uk.ibm.com ([195.75.94.104]:53205) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aujp8-0007Ie-Gr for qemu-devel@nongnu.org; Mon, 25 Apr 2016 12:57:26 -0400 Received: from localhost by e06smtp08.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Apr 2016 17:57:25 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp08.uk.ibm.com (192.168.101.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 25 Apr 2016 17:57:24 +0100 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: cornelia.huck@de.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 27DC02190056 for ; Mon, 25 Apr 2016 17:57:01 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3PGvNhn7602604 for ; Mon, 25 Apr 2016 16:57:23 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3PGvN7b013237 for ; Mon, 25 Apr 2016 10:57:23 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3PGvL3S013203 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Mon, 25 Apr 2016 10:57:22 -0600 From: Cornelia Huck To: qemu-devel@nongnu.org Date: Mon, 25 Apr 2016 18:57:16 +0200 Message-Id: <1461603440-67287-3-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1461603440-67287-1-git-send-email-cornelia.huck@de.ibm.com> References: <1461603440-67287-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16042516-0033-0000-0000-000012C3491C X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.104 Subject: [Qemu-devel] [PATCH for-2.7 2/6] virtio-bus: have callers tolerate new host notifier api X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: famz@redhat.com, mst@redhat.com, borntraeger@de.ibm.com, stefanha@redhat.com, Cornelia Huck , pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Have vhost and dataplane use the new api for transports that have been converted. Signed-off-by: Cornelia Huck --- 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 3cb97c9..29e2ce7 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -132,7 +132,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)"); @@ -220,7 +221,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; @@ -256,6 +260,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; @@ -280,7 +285,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 4400718..818fada 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1114,14 +1114,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; @@ -1131,7 +1135,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); @@ -1155,7 +1163,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);