aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorLongpeng <longpeng2@huawei.com>2022-12-27 15:20:13 +0800
committerMichael S. Tsirkin <mst@redhat.com>2023-01-08 01:54:22 -0500
commit8771589b6f81d66969808460fddf5a85b2237ac4 (patch)
tree37b67c881fcadf8c2bf59a2fec24dc6b2efabd27 /hw/virtio
parentbf7a2ad8b6dfab4adb40db44022e4c424b56421e (diff)
vhost: simplify vhost_dev_enable_notifiers
Simplify the error path in vhost_dev_enable_notifiers by using vhost_dev_disable_notifiers directly. Signed-off-by: Longpeng <longpeng2@huawei.com> Message-Id: <20221227072015.3134-2-longpeng2@huawei.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/vhost.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 2c566dc539..87c49fa679 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.