[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 40/51] vhost: simplify vhost_dev_enable_notifiers
From: |
Michael S. Tsirkin |
Subject: |
[PULL 40/51] vhost: simplify vhost_dev_enable_notifiers |
Date: |
Thu, 5 Jan 2023 04:16:31 -0500 |
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>
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>
---
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 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.
--
MST
- [PULL 27/51] include/hw/pci: Break inclusion loop pci_bridge.h and cxl.h, (continued)
- [PULL 27/51] include/hw/pci: Break inclusion loop pci_bridge.h and cxl.h, Michael S. Tsirkin, 2023/01/05
- [PULL 30/51] include/hw/pci: Clean up a few things checkpatch.pl would flag, Michael S. Tsirkin, 2023/01/05
- [PULL 29/51] include/hw/cxl: Include hw/cxl/*.h where needed, Michael S. Tsirkin, 2023/01/05
- [PULL 31/51] include/hw/pci: Split pci_device.h off pci.h, Michael S. Tsirkin, 2023/01/05
- [PULL 34/51] include/hw/virtio: Break inclusion loop, Michael S. Tsirkin, 2023/01/05
- [PULL 35/51] include: Include headers where needed, Michael S. Tsirkin, 2023/01/05
- [PULL 36/51] include: Don't include qemu/osdep.h, Michael S. Tsirkin, 2023/01/05
- [PULL 37/51] docs/devel: Rules on #include in headers, Michael S. Tsirkin, 2023/01/05
- [PULL 39/51] vdpa: harden the error path if get_iova_range failed, Michael S. Tsirkin, 2023/01/05
- [PULL 40/51] vhost: simplify vhost_dev_enable_notifiers,
Michael S. Tsirkin <=
- [PULL 41/51] vhost: configure all host notifiers in a single MR transaction, Michael S. Tsirkin, 2023/01/05
- [PULL 43/51] virtio-pci: fix proxy->vector_irqfd leak in virtio_pci_set_guest_notifiers, Michael S. Tsirkin, 2023/01/05
- [PULL 38/51] vdpa-dev: get iova range explicitly, Michael S. Tsirkin, 2023/01/05
- [PULL 42/51] vdpa: commit all host notifier MRs in a single MR transaction, Michael S. Tsirkin, 2023/01/05
- [PULL 44/51] tests: virt: Allow changes to PPTT test table, Michael S. Tsirkin, 2023/01/05
- [PULL 45/51] hw/acpi/aml-build: Only generate cluster node in PPTT when specified, Michael S. Tsirkin, 2023/01/05
- [PULL 46/51] tests: virt: Update expected ACPI tables for virt test, Michael S. Tsirkin, 2023/01/05
- [PULL 47/51] tests: acpi: Add and whitelist *.topology blobs, Michael S. Tsirkin, 2023/01/05
- [PULL 48/51] tests: acpi: aarch64: Add topology test for aarch64, Michael S. Tsirkin, 2023/01/05
- [PULL 49/51] tests: acpi: aarch64: Add *.topology tables, Michael S. Tsirkin, 2023/01/05