All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [PATCH hci-8.1] vhost-blk: reorder stopping sequence
@ 2026-11-18 14:50 Andrey Zhadchenko
  2026-11-18 15:00 ` no-reply
  2026-11-18 15:20 ` Andrey Drobyshev
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Zhadchenko @ 2026-11-18 14:50 UTC (permalink / raw)
  To: andrey.drobyshev; +Cc: svt-core, den

Setting backend to -1 drains all in-flight requests. But if we
remove the notifiers beforehand, the requests are never signaled
as completed and guest is not notified after qemu CPR. Any IO
completion on the device unstucks the queue because used ring
is correct but the irqs are lost.
Remove the notifiers after device stop just like vhost-user-blk
or vhost-scsi.

https://virtuozzo.atlassian.net/browse/VSTOR-155598
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
---
 hw/block/vhost-blk.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index abddff02c6d..4cebc91d33e 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -138,12 +138,6 @@ static void vhost_blk_stop(VirtIODevice *vdev)
         return;
     }
 
-    ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
-    if (ret < 0) {
-        error_report("vhost-blk: unable to unbind guest notifiers");
-    }
-    vhost_dev_disable_notifiers(&s->dev, vdev);
-
     /*
      * Detach the backend before vhost_dev_stop() samples the vring base,
      * to stop the kernel worker from further fetching.
@@ -158,6 +152,12 @@ static void vhost_blk_stop(VirtIODevice *vdev)
 
     vhost_dev_stop(&s->dev, vdev, false);
 
+    ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
+    if (ret < 0) {
+        error_report("vhost-blk: unable to unbind guest notifiers");
+    }
+    vhost_dev_disable_notifiers(&s->dev, vdev);
+
     s->vhost_started = false;
 }
 
-- 
2.43.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH hci-8.1] vhost-blk: reorder stopping sequence
  2026-11-18 14:50 [PATCH hci-8.1] vhost-blk: reorder stopping sequence Andrey Zhadchenko
@ 2026-11-18 15:00 ` no-reply
  2026-11-18 15:20 ` Andrey Drobyshev
  1 sibling, 0 replies; 3+ messages in thread
From: no-reply @ 2026-11-18 15:00 UTC (permalink / raw)
  To: Andrey Zhadchenko, andrey.drobyshev; +Cc: svt-core, den

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] vhost-blk: bug-fix commit lacks Fixes: trailer for 8ac98a51b27f
--

commit 901d9860f12c9c1369196a0dde8aae76f91ce496
Author: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>

vhost-blk: reorder stopping sequence

This commit moves the guest notifier teardown and vhost_dev_disable_notifiers() in vhost_blk_stop() to after the backend detach and vhost_dev_stop(). The goal is that the completions drained by VHOST_BLK_SET_BACKEND(fd = -1) still reach the guest after qemu CPR.

> vhost-blk: reorder stopping sequence
>
> Setting backend to -1 drains all in-flight requests. But if we
> remove the notifiers beforehand, the requests are never signaled
> as completed and guest is not notified after qemu CPR. Any IO
> completion on the device unstucks the queue because used ring
> is correct but the irqs are lost.
> Remove the notifiers after device stop just like vhost-user-blk
> or vhost-scsi.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-155598
> Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>

[Severity: Low]
This looks like a bug fix for the lost-interrupt window that opened when the backend drain was added in vhost_blk_stop(). Should this include:

  Fixes: 8ac98a51b27f ("VZ: vhost-blk: detach backend before sampling vring base on stop #VSTOR-133464")

That commit placed the VHOST_BLK_SET_BACKEND(fd = -1) drain after the guest notifiers and host notifiers were already removed. Before it there was no drain step, so the window did not exist.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118145012.216512-1-andrey.zhadchenko@virtuozzo.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH hci-8.1] vhost-blk: reorder stopping sequence
  2026-11-18 14:50 [PATCH hci-8.1] vhost-blk: reorder stopping sequence Andrey Zhadchenko
  2026-11-18 15:00 ` no-reply
@ 2026-11-18 15:20 ` Andrey Drobyshev
  1 sibling, 0 replies; 3+ messages in thread
From: Andrey Drobyshev @ 2026-11-18 15:20 UTC (permalink / raw)
  To: Andrey Zhadchenko; +Cc: svt-core, den

LGTM, Ack
Applied on hci-8.1, added:

Fixes: 0ff3cb5ff28f ("block: add vhost-blk backend")


On 11/18/26 4:50 PM, Andrey Zhadchenko wrote:
> Setting backend to -1 drains all in-flight requests. But if we
> remove the notifiers beforehand, the requests are never signaled
> as completed and guest is not notified after qemu CPR. Any IO
> completion on the device unstucks the queue because used ring
> is correct but the irqs are lost.
> Remove the notifiers after device stop just like vhost-user-blk
> or vhost-scsi.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-155598
> Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
> ---
>  hw/block/vhost-blk.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
> index abddff02c6d..4cebc91d33e 100644
> --- a/hw/block/vhost-blk.c
> +++ b/hw/block/vhost-blk.c
> @@ -138,12 +138,6 @@ static void vhost_blk_stop(VirtIODevice *vdev)
>          return;
>      }
>  
> -    ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
> -    if (ret < 0) {
> -        error_report("vhost-blk: unable to unbind guest notifiers");
> -    }
> -    vhost_dev_disable_notifiers(&s->dev, vdev);
> -
>      /*
>       * Detach the backend before vhost_dev_stop() samples the vring base,
>       * to stop the kernel worker from further fetching.
> @@ -158,6 +152,12 @@ static void vhost_blk_stop(VirtIODevice *vdev)
>  
>      vhost_dev_stop(&s->dev, vdev, false);
>  
> +    ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
> +    if (ret < 0) {
> +        error_report("vhost-blk: unable to unbind guest notifiers");
> +    }
> +    vhost_dev_disable_notifiers(&s->dev, vdev);
> +
>      s->vhost_started = false;
>  }
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-18 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 14:50 [PATCH hci-8.1] vhost-blk: reorder stopping sequence Andrey Zhadchenko
2026-11-18 15:00 ` no-reply
2026-11-18 15:20 ` Andrey Drobyshev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.