* [PATCH hci-8.1 / hci-8.2 1/5] vhost-blk: drop redundant vhost_blk_stop() call
2026-11-19 17:08 [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes Andrey Drobyshev
@ 2026-11-19 17:08 ` Andrey Drobyshev
2026-11-19 17:11 ` no-reply
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 2/5] vhost-blk: drop dead NULL check of the vm state handler Andrey Drobyshev
` (4 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Andrey Drobyshev @ 2026-11-19 17:08 UTC (permalink / raw)
To: svt-core; +Cc: alexander.ivanov, andrey.zhadchenko, den, andrey.drobyshev
vhost_blk_reset() already calls vhost_blk_stop(), this 2nd call is
redundant. Drop it.
Pure cleanup, no functional change.
Fixes: c08e1fb19635 ("vhost_blk: support state saving #VSTOR-90838")
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
hw/block/vhost-blk.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index d8bbfcaff86..6938db9d718 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -203,7 +203,6 @@ static void vhost_blk_vm_state(void *opaque, bool running, RunState state)
VirtIODevice *vdev = opaque;
if (state == RUN_STATE_FINISH_MIGRATE || state == RUN_STATE_PAUSED) {
- vhost_blk_stop(vdev);
vhost_blk_reset(vdev);
} else if (state == RUN_STATE_RUNNING) {
vhost_blk_start(vdev);
--
2.47.1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH hci-8.1 / hci-8.2 1/5] vhost-blk: drop redundant vhost_blk_stop() call
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 1/5] vhost-blk: drop redundant vhost_blk_stop() call Andrey Drobyshev
@ 2026-11-19 17:11 ` no-reply
0 siblings, 0 replies; 12+ messages in thread
From: no-reply @ 2026-11-19 17:11 UTC (permalink / raw)
To: Andrey Drobyshev, svt-core; +Cc: alexander.ivanov, andrey.zhadchenko, den
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] vhost-blk: Fixes: trailer on a self-described pure cleanup patch
--
commit 5d36725bd654270b896bfd3c7562fadc459bf93c
Author: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> vhost-blk: drop redundant vhost_blk_stop() call
>
> vhost_blk_reset() already calls vhost_blk_stop(), this 2nd call is
> redundant. Drop it.
>
> Pure cleanup, no functional change.
>
> Fixes: c08e1fb19635 ("vhost_blk: support state saving #VSTOR-90838")
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
[Severity: Low]
The message calls this a pure cleanup with no functional change, so is the
Fixes: tag appropriate?
vhost_blk_reset() starts with vhost_blk_stop(), which returns early when
s->vhost_started is false. The removed call was therefore a no-op, and
there is no bug in c08e1fb19635 ("vhost_blk: support state saving
#VSTOR-90838") to fix. The tag could pull this patch into stable or
downstream backport tooling for no functional reason. Could the tag be
dropped, or the message reworded to say the call became redundant with that
commit?
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261119170855.472905-1-andrey.drobyshev@virtuozzo.com?part=1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH hci-8.1 / hci-8.2 2/5] vhost-blk: drop dead NULL check of the vm state handler
2026-11-19 17:08 [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes Andrey Drobyshev
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 1/5] vhost-blk: drop redundant vhost_blk_stop() call Andrey Drobyshev
@ 2026-11-19 17:08 ` Andrey Drobyshev
2026-11-19 17:11 ` no-reply
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 3/5] vhost-blk: fix vqs leak on unrealize Andrey Drobyshev
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Andrey Drobyshev @ 2026-11-19 17:08 UTC (permalink / raw)
To: svt-core; +Cc: alexander.ivanov, andrey.zhadchenko, den, andrey.drobyshev
qemu_add_vm_change_state_handler() never returns NULL, so the check
cannot fire. Drop it.
Pure cleanup, no functional change.
Fixes: d31b67263a21 ("hw/block/vhost-blk: support migration #PSBM-152243")
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
hw/block/vhost-blk.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index 6938db9d718..ce85c49c991 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -648,9 +648,6 @@ static void vhost_blk_device_realize(DeviceState *dev, Error **errp)
s->dev.acked_features = 0;
s->mighand = qemu_add_vm_change_state_handler(vhost_blk_vm_state, vdev);
- if (!s->mighand) {
- goto cleanup;
- }
ret = vhost_dev_init(&s->dev, (void *)((size_t)s->vhostfd),
VHOST_BACKEND_TYPE_KERNEL, 0, NULL);
--
2.47.1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH hci-8.1 / hci-8.2 2/5] vhost-blk: drop dead NULL check of the vm state handler
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 2/5] vhost-blk: drop dead NULL check of the vm state handler Andrey Drobyshev
@ 2026-11-19 17:11 ` no-reply
0 siblings, 0 replies; 12+ messages in thread
From: no-reply @ 2026-11-19 17:11 UTC (permalink / raw)
To: Andrey Drobyshev, svt-core; +Cc: alexander.ivanov, andrey.zhadchenko, den
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] vhost-blk: Fixes: trailer on a pure-cleanup commit removing dead
code
--
commit c455357faa99190cb0ae75b5f796ae404b6e9291
Author: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> vhost-blk: drop dead NULL check of the vm state handler
>
> qemu_add_vm_change_state_handler() never returns NULL, so the check
> cannot fire. Drop it.
>
> Pure cleanup, no functional change.
>
> Fixes: d31b67263a21 ("hw/block/vhost-blk: support migration #PSBM-152243")
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
[Severity: Low]
Should this Fixes: tag be there? The message calls this a pure cleanup with no functional change. The removed "if (!s->mighand) goto cleanup;" was unreachable, so d31b67263a21 ("hw/block/vhost-blk: support migration #PSBM-152243") left no bug to fix. A Fixes: tag normally marks a bug fix for stable and backport tooling, and here it contradicts the message. Could the tag be dropped, or the message reworded to say what is being fixed?
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261119170855.472905-1-andrey.drobyshev@virtuozzo.com?part=2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH hci-8.1 / hci-8.2 3/5] vhost-blk: fix vqs leak on unrealize
2026-11-19 17:08 [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes Andrey Drobyshev
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 1/5] vhost-blk: drop redundant vhost_blk_stop() call Andrey Drobyshev
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 2/5] vhost-blk: drop dead NULL check of the vm state handler Andrey Drobyshev
@ 2026-11-19 17:08 ` Andrey Drobyshev
2026-11-19 17:12 ` no-reply
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 4/5] vhost-blk: stop the device " Andrey Drobyshev
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Andrey Drobyshev @ 2026-11-19 17:08 UTC (permalink / raw)
To: svt-core; +Cc: alexander.ivanov, andrey.zhadchenko, den, andrey.drobyshev
vhost_dev_cleanup() zeroes the vhost_dev, so the g_free(s->dev.vqs)
after it frees NULL and the virtqueue array leaks on every unrealize.
Save the pointer before the cleanup and free that, as vhost-scsi does.
Fixes: 0ff3cb5ff28f ("block: add vhost-blk backend")
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
hw/block/vhost-blk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index ce85c49c991..8158fc14a26 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -686,6 +686,7 @@ static void vhost_blk_device_unrealize(DeviceState *dev)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VHostBlk *s = VHOST_BLK(dev);
+ struct vhost_virtqueue *vqs = s->dev.vqs;
vhost_blk_uevent_detach(s);
qemu_del_vm_change_state_handler(s->mighand);
@@ -695,7 +696,7 @@ static void vhost_blk_device_unrealize(DeviceState *dev)
qemu_close(s->backend_fd);
s->backend_fd = -1;
}
- g_free(s->dev.vqs);
+ g_free(vqs);
virtio_cleanup(vdev);
}
--
2.47.1
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH hci-8.1 / hci-8.2 4/5] vhost-blk: stop the device on unrealize
2026-11-19 17:08 [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes Andrey Drobyshev
` (2 preceding siblings ...)
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 3/5] vhost-blk: fix vqs leak on unrealize Andrey Drobyshev
@ 2026-11-19 17:08 ` Andrey Drobyshev
2026-11-19 17:13 ` no-reply
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 5/5] vhost-blk: don't leak the vhost fd across cpr-exec Andrey Drobyshev
2026-11-20 12:36 ` [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes Andrey Zhadchenko
5 siblings, 1 reply; 12+ messages in thread
From: Andrey Drobyshev @ 2026-11-19 17:08 UTC (permalink / raw)
To: svt-core; +Cc: alexander.ivanov, andrey.zhadchenko, den, andrey.drobyshev
vhost_blk_device_unrealize() calls vhost_blk_set_status(vdev, 0) to stop
the device, as vhost-scsi does. But vhost_blk_set_status() ignores a
status without DRIVER_OK, so the call does nothing.
A device which is still started is then torn down with its vrings mapped
and its guest and host notifiers bound. This happens when the guest
ejects a disk no guest driver has reset: SeaBIOS sets DRIVER_OK on the
disks it probes and leaves them so, and a guest OS without a virtio
driver never resets them.
Call vhost_blk_stop() instead.
Fixes: 0ff3cb5ff28f ("block: add vhost-blk backend")
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
hw/block/vhost-blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index 8158fc14a26..a9b99ec4bc9 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -690,7 +690,7 @@ static void vhost_blk_device_unrealize(DeviceState *dev)
vhost_blk_uevent_detach(s);
qemu_del_vm_change_state_handler(s->mighand);
- vhost_blk_set_status(vdev, 0);
+ vhost_blk_stop(vdev);
vhost_dev_cleanup(&s->dev);
if (s->backend_fd >= 0) {
qemu_close(s->backend_fd);
--
2.47.1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH hci-8.1 / hci-8.2 4/5] vhost-blk: stop the device on unrealize
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 4/5] vhost-blk: stop the device " Andrey Drobyshev
@ 2026-11-19 17:13 ` no-reply
0 siblings, 0 replies; 12+ messages in thread
From: no-reply @ 2026-11-19 17:13 UTC (permalink / raw)
To: Andrey Drobyshev, svt-core; +Cc: alexander.ivanov, andrey.zhadchenko, den
> vhost_blk_device_unrealize() calls vhost_blk_set_status(vdev, 0) to stop
> the device, as vhost-scsi does. But vhost_blk_set_status() ignores a
> status without DRIVER_OK, so the call does nothing.
>
> A device which is still started is then torn down with its vrings mapped
> and its guest and host notifiers bound. This happens when the guest
> ejects a disk no guest driver has reset: SeaBIOS sets DRIVER_OK on the
> disks it probes and leaves them so, and a guest OS without a virtio
> driver never resets them.
>
> Call vhost_blk_stop() instead.
>
> Fixes: 0ff3cb5ff28f ("block: add vhost-blk backend")
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261119170855.472905-1-andrey.drobyshev@virtuozzo.com?part=4
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH hci-8.1 / hci-8.2 5/5] vhost-blk: don't leak the vhost fd across cpr-exec
2026-11-19 17:08 [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes Andrey Drobyshev
` (3 preceding siblings ...)
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 4/5] vhost-blk: stop the device " Andrey Drobyshev
@ 2026-11-19 17:08 ` Andrey Drobyshev
2026-11-19 17:13 ` no-reply
2026-11-20 12:36 ` [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes Andrey Zhadchenko
5 siblings, 1 reply; 12+ messages in thread
From: Andrey Drobyshev @ 2026-11-19 17:08 UTC (permalink / raw)
To: svt-core; +Cc: alexander.ivanov, andrey.zhadchenko, den, andrey.drobyshev
The vhost fd is opened with a plain open(), so it has no close-on-exec
flag. cpr-exec clears that flag only on the fds it preserves and closes
nothing else, so the old fd is carried into the new QEMU, which opens
its own one in realize. Every cpr-exec thus leaks an fd and a kernel
vhost-blk instance per disk.
Open it with qemu_open(), which sets O_CLOEXEC and reports the errno, and
close it with qemu_close() on the realize error path.
Fixes: 0ff3cb5ff28f ("block: add vhost-blk backend")
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
hw/block/vhost-blk.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index a9b99ec4bc9..8ecb6a441e4 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -639,9 +639,8 @@ static void vhost_blk_device_realize(DeviceState *dev, Error **errp)
virtio_add_queue(vdev, conf->queue_size, vhost_blk_handle_output);
}
- s->vhostfd = open("/dev/vhost-blk", O_RDWR);
+ s->vhostfd = qemu_open("/dev/vhost-blk", O_RDWR, errp);
if (s->vhostfd < 0) {
- error_setg(errp, "vhost-blk: unable to open /dev/vhost-blk");
goto cleanup;
}
@@ -667,7 +666,7 @@ cleanup:
}
g_free(vqs);
if (s->vhostfd >= 0) {
- close(s->vhostfd);
+ qemu_close(s->vhostfd);
s->vhostfd = -1;
}
if (s->backend_fd >= 0) {
--
2.47.1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes
2026-11-19 17:08 [PATCH hci-8.1 / hci-8.2 0/5] vhost-blk: a bunch of cleanups and small fixes Andrey Drobyshev
` (4 preceding siblings ...)
2026-11-19 17:08 ` [PATCH hci-8.1 / hci-8.2 5/5] vhost-blk: don't leak the vhost fd across cpr-exec Andrey Drobyshev
@ 2026-11-20 12:36 ` Andrey Zhadchenko
5 siblings, 0 replies; 12+ messages in thread
From: Andrey Zhadchenko @ 2026-11-20 12:36 UTC (permalink / raw)
To: Andrey Drobyshev, svt-core; +Cc: alexander.ivanov, den
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
On 11/19/26 18:08, Andrey Drobyshev wrote:
> Just cleanup patches. No real functional change. Intended to be
> squashed on next rebase.
>
> Andrey Drobyshev (5):
> vhost-blk: drop redundant vhost_blk_stop() call
> vhost-blk: drop dead NULL check of the vm state handler
> vhost-blk: fix vqs leak on unrealize
> vhost-blk: stop the device on unrealize
> vhost-blk: don't leak the vhost fd across cpr-exec
>
> hw/block/vhost-blk.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread