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>
This commit is contained in:
parent
bf7a2ad8b6
commit
8771589b6f
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user