[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/4] vhost: simplify vhost_dev_init() fail_busyloop label
From: |
Michael S. Tsirkin |
Subject: |
[PULL 4/4] vhost: simplify vhost_dev_init() fail_busyloop label |
Date: |
Tue, 2 Mar 2021 09:21:17 -0500 |
From: Stefan Hajnoczi <stefanha@redhat.com>
Requiring a conditional for every goto is tedious:
if (busyloop_timeout) {
goto fail_busyloop;
} else {
goto fail;
}
Move the conditional to into the fail_busyloop label so that it's safe
to jump to this label unconditionally.
This change makes the migrate_add_blocker() error case more consistent.
It jumped to fail_busyloop unconditionally whereas the memslots limits
error case was conditional.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210222114931.272308-1-stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6e17d631f7..2a01662b08 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1388,18 +1388,16 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
error_report("vhost backend memory slots limit is less"
" than current number of present memory slots");
r = -1;
- if (busyloop_timeout) {
- goto fail_busyloop;
- } else {
- goto fail;
- }
+ goto fail_busyloop;
}
return 0;
fail_busyloop:
- while (--i >= 0) {
- vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
+ if (busyloop_timeout) {
+ while (--i >= 0) {
+ vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
+ }
}
fail:
hdev->nvqs = n_initialized_vqs;
--
MST
- [PULL 0/4] pc,virtio,pci: bug fixes, Michael S. Tsirkin, 2021/03/02
- [PULL 1/4] i386/acpi: restore device paths for pre-5.1 vms, Michael S. Tsirkin, 2021/03/02
- [PULL 3/4] hw/pci: Have safer pcie_bus_realize() by checking error path, Michael S. Tsirkin, 2021/03/02
- [PULL 4/4] vhost: simplify vhost_dev_init() fail_busyloop label,
Michael S. Tsirkin <=
- [PULL 2/4] virtio-net: handle zero mac for a vdpa peer, Michael S. Tsirkin, 2021/03/02
- Re: [PULL 0/4] pc,virtio,pci: bug fixes, Peter Maydell, 2021/03/03