[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 1/3] vhost: simplify vhost_dev_enable_notifiers
From: |
Longpeng(Mike) |
Subject: |
[PATCH v3 1/3] vhost: simplify vhost_dev_enable_notifiers |
Date: |
Tue, 27 Dec 2022 15:20:13 +0800 |
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