All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Longpeng(Mike)" via <qemu-devel@nongnu.org>
To: <stefanha@redhat.com>, <mst@redhat.com>, <jasowang@redhat.com>,
	<philmd@linaro.org>
Cc: <cohuck@redhat.com>, <sgarzare@redhat.com>, <pbonzini@redhat.com>,
	<arei.gonglei@huawei.com>, <yechuan@huawei.com>,
	<huangzhichao@huawei.com>, <qemu-devel@nongnu.org>,
	Longpeng <longpeng2@huawei.com>
Subject: [PATCH v3 1/3] vhost: simplify vhost_dev_enable_notifiers
Date: Tue, 27 Dec 2022 15:20:13 +0800	[thread overview]
Message-ID: <20221227072015.3134-2-longpeng2@huawei.com> (raw)
In-Reply-To: <20221227072015.3134-1-longpeng2@huawei.com>

From: Longpeng <longpeng2@huawei.com>

Simplify the error path in vhost_dev_enable_notifiers by using
vhost_dev_disable_notifiers directly.

Signed-off-by: Longpeng <longpeng2@huawei.com>
---
 hw/virtio/vhost.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index fdcd1a8fdf..5994559da8 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1551,7 +1551,7 @@ void vhost_dev_cleanup(struct vhost_dev *hdev)
 int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
 {
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
-    int i, r, e;
+    int i, r;
 
     /* We will pass the notifiers to the kernel, make sure that QEMU
      * doesn't interfere.
@@ -1559,7 +1559,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
     r = virtio_device_grab_ioeventfd(vdev);
     if (r < 0) {
         error_report("binding does not support host notifiers");
-        goto fail;
+        return r;
     }
 
     for (i = 0; i < hdev->nvqs; ++i) {
@@ -1567,24 +1567,12 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
                                          true);
         if (r < 0) {
             error_report("vhost VQ %d notifier binding failed: %d", i, -r);
-            goto fail_vq;
+            vhost_dev_disable_notifiers(hdev, vdev);
+            return r;
         }
     }
 
     return 0;
-fail_vq:
-    while (--i >= 0) {
-        e = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i,
-                                         false);
-        if (e < 0) {
-            error_report("vhost VQ %d notifier cleanup error: %d", i, -r);
-        }
-        assert (e >= 0);
-        virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i);
-    }
-    virtio_device_release_ioeventfd(vdev);
-fail:
-    return r;
 }
 
 /* Stop processing guest IO notifications in vhost.
-- 
2.23.0



  reply	other threads:[~2022-12-27  7:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27  7:20 [PATCH v3 0/3] two optimizations to speed up the start time Longpeng(Mike) via
2022-12-27  7:20 ` Longpeng(Mike) via [this message]
2022-12-27  7:20 ` [PATCH v3 2/3] vhost: configure all host notifiers in a single MR transaction Longpeng(Mike) via
2022-12-27 16:43   ` Philippe Mathieu-Daudé
2022-12-27 17:54     ` Michael S. Tsirkin
2022-12-28 13:12       ` Philippe Mathieu-Daudé
2022-12-29  5:18         ` longpeng2--- via
2022-12-27  7:20 ` [PATCH v3 3/3] vdpa: commit all host notifier MRs " Longpeng(Mike) via
2022-12-27 16:51   ` Philippe Mathieu-Daudé
2022-12-27 17:56     ` Michael S. Tsirkin
2022-12-28 13:14       ` Philippe Mathieu-Daudé

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=20221227072015.3134-2-longpeng2@huawei.com \
    --to=qemu-devel@nongnu.org \
    --cc=arei.gonglei@huawei.com \
    --cc=cohuck@redhat.com \
    --cc=huangzhichao@huawei.com \
    --cc=jasowang@redhat.com \
    --cc=longpeng2@huawei.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=yechuan@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.