All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: andrey.zhadchenko@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, svt-core@virtuozzo.com
Subject: [PATCH hci-8.2 v4 3/5] vhost-blk: stop vhost on every VM stop #VSTOR-152175
Date: Tue,  1 Dec 2026 10:18:16 +0100	[thread overview]
Message-ID: <20261201091818.1894308-4-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261201091818.1894308-1-alexander.ivanov@virtuozzo.com>

vhost is stopped only on pause and at the end of a migration. In any
other stopped state it keeps running in the kernel, so the device
state saved there is stale: vhost_dev_stop(), which fetches the vring
indexes from the kernel, has not run.

This affects savevm, which stops the VM with the save-vm reason, and
a migration of a VM stopped for debug, shutdown, a guest panic or a
watchdog: the VM is not live, so the migration does not run the state
handlers again. The destination then processes anew the requests the
source completed after the indexes were last fetched.

Stop vhost whenever the VM stops and start it whenever the VM runs.

https://virtuozzo.atlassian.net/browse/VSTOR-152175

Fixes: d31b67263a21 ("hw/block/vhost-blk: support migration #PSBM-152243")
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
 hw/block/vhost-blk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index 164423f782c..124885a2b30 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -267,10 +267,10 @@ 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_reset(vdev);
-    } else if (state == RUN_STATE_RUNNING) {
+    if (running) {
         vhost_blk_start(vdev);
+    } else {
+        vhost_blk_reset(vdev);
     }
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-12-01  9:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:18 [PATCH hci-8.2 v4 0/5] vhost-blk: support the werror/rerror policies Alexander Ivanov
2026-12-01  9:18 ` [PATCH hci-8.2 v4 1/5] linux-headers: add the vhost-blk held request ioctls #VSTOR-152175 Alexander Ivanov
2026-12-01  9:21   ` no-reply
2026-12-01  9:18 ` [PATCH hci-8.2 v4 2/5] vhost-blk: add the werror and rerror properties #VSTOR-152175 Alexander Ivanov
2026-12-01  9:18 ` Alexander Ivanov [this message]
2026-12-01  9:24   ` [PATCH hci-8.2 v4 3/5] vhost-blk: stop vhost on every VM stop #VSTOR-152175 no-reply
2026-12-01  9:18 ` [PATCH hci-8.2 v4 4/5] vhost-blk: pause the VM on a request failed with ENOSPC #VSTOR-152175 Alexander Ivanov
2026-12-01  9:25   ` no-reply
2026-12-01  9:41     ` Alexander Ivanov
2026-12-01  9:18 ` [PATCH hci-8.2 v4 5/5] vhost-blk: migrate the held requests #VSTOR-152175 Alexander Ivanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201091818.1894308-4-alexander.ivanov@virtuozzo.com \
    --to=alexander.ivanov@virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=svt-core@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.