vhost: simplify vhost_dev_init() error-path
No reason to rollback setting up busyloop timeout on failure. We don't do such rollback for other things we setup in backend. Also, look at vhost_net_init() in hw/net/vhost_net.c: we may fail after successfully called vhost_dev_init(), and in this case we'll just call vhost_dev_cleanup(), which doesn't rollback busyloop timeout. So, let's keep it simple. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Acked-by: Raphael Norwitz <raphael.s.norwitz@gmail.com> Reviewed-by: Daniil Tatianin <d-tatianin@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Lei Yang <leiyang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260420200339.708640-17-vsementsov@yandex-team.ru>
Vladimir Sementsov-Ogievskiy committed
Apr 20, 2026 at 23:03 UTC
ef817ddfd90f158b9769baaadbdb9fb2a52d3018
1 file changed
+3
-9
hw/virtio/vhost.c
+3
-9
@@ -1624,7 +1624,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
1624
busyloop_timeout);
1625
if (r < 0) {
1626
error_setg_errno(errp, -r, "Failed to set busyloop timeout");
1627
- goto fail_busyloop;
1627
+ goto fail;
1628
}
1629
}
1630
}
@@ -1664,7 +1664,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
1664
if (hdev->migration_blocker != NULL) {
1665
r = migrate_add_blocker_normal(&hdev->migration_blocker, errp);
1666
if (r < 0) {
1667
- goto fail_busyloop;
1667
+ goto fail;
1668
}
1669
}
1670
@@ -1696,17 +1696,11 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
1696
" than current number of used (%d) and reserved (%d)"
1697
" memory slots for memory devices.", limit, used, reserved);
1698
r = -EINVAL;
1699
- goto fail_busyloop;
1699
+ goto fail;
1700
}
1701
1702
return 0;
1703
1704
-fail_busyloop:
1705
- if (busyloop_timeout) {
1706
- while (--i >= 0) {
1707
- vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
1708
- }
1709
- }
1704
fail:
1705
hdev->nvqs = n_initialized_vqs;
1706
vhost_dev_cleanup(hdev);