From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
To: svt-core@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, den@openvz.org
Subject: [PATCH hci-dev] vfio/migration: leave the device alone when the guest shuts down #VSTOR-153976
Date: Sat, 7 Nov 2026 22:56:26 +0200 [thread overview]
Message-ID: <20261107205626.983714-1-andrey.drobyshev@virtuozzo.com> (raw)
When the guest shuts down and QEMU runs with -no-shutdown, the VM stays
stopped and can only be reset or quit. A libvirt soft reboot is exactly
that: guest shutdown, system_reset, cont. Today vfio_vmstate_change()
treats this stop like any other and moves the device to STOP, then cont
brings it back to RUNNING.
NVIDIA's vGPU manager (595.71.03) takes that STOP for the start of a
migration, finds no guest driver, breaks its dirty page tracking and
never repairs it when the driver loads again. Every live migration of
the VM after a soft reboot then fails: "Error saving page in pipelined
mode".
Do not touch the device state on a guest shutdown. There is nothing to
quiesce, and the reset that must follow resets the device anyway.
Pause, migration and savevm still stop the device as before.
With this patch applied, soft reboot + subsequent live migration pass
successfully.
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
hw/vfio/migration.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 7e7fb496bbe..c02b6a199b8 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -899,6 +899,11 @@ static void vfio_vmstate_change_prepare(void *opaque, bool running,
return;
}
+ /* The guest has shut down, the device state stays as it is */
+ if (!running && state == RUN_STATE_SHUTDOWN) {
+ return;
+ }
+
new_state = migration->device_state == VFIO_DEVICE_STATE_PRE_COPY ?
VFIO_DEVICE_STATE_PRE_COPY_P2P :
VFIO_DEVICE_STATE_RUNNING_P2P;
@@ -936,6 +941,15 @@ static void vfio_vmstate_change(void *opaque, bool running, RunState state)
return;
}
+ /*
+ * The guest has shut down and QEMU keeps the VM stopped. It can only
+ * be reset or quit now, so leave the device state as it is: the reset
+ * resets the device too.
+ */
+ if (!running && state == RUN_STATE_SHUTDOWN) {
+ return;
+ }
+
if (running) {
new_state = VFIO_DEVICE_STATE_RUNNING;
} else {
--
2.47.1
next reply other threads:[~2026-11-07 20:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 20:56 Andrey Drobyshev [this message]
2026-11-07 21:00 ` no-reply
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=20261107205626.983714-1-andrey.drobyshev@virtuozzo.com \
--to=andrey.drobyshev@virtuozzo.com \
--cc=den@openvz.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox