public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Erik Fastermann <e.fastermann@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [RFC PATCH pve-qemu] savevm-async: fix stuck paused vm after snapshot
Date: Wed, 26 Aug 2026 15:30:46 +0200	[thread overview]
Message-ID: <d052f289-1c33-4db7-814b-aa4664446666@proxmox.com> (raw)
In-Reply-To: <20260612075345.110118-1-e.fastermann@proxmox.com>

Am 12.06.26 um 9:53 AM schrieb Erik Fastermann:
> When creating a snapshot of a paused vm, the vm hung indefinitely in the
> state "paused (finish-migrate)" and had to be restarted. This patch
> fixes this by only transitioning the vm run state if the vm was
> currently running.
> 
> Signed-off-by: Erik Fastermann <e.fastermann@proxmox.com>
> ---
>  ...c-fix-stuck-paused-vm-after-snapshot.patch | 48 +++++++++++++++++++
>  debian/patches/series                         |  1 +
>  2 files changed, 49 insertions(+)
>  create mode 100644 debian/patches/pve/0047-savevm-async-fix-stuck-paused-vm-after-snapshot.patch
> 
> diff --git a/debian/patches/pve/0047-savevm-async-fix-stuck-paused-vm-after-snapshot.patch b/debian/patches/pve/0047-savevm-async-fix-stuck-paused-vm-after-snapshot.patch
> new file mode 100644
> index 0000000..46f0422
> --- /dev/null
> +++ b/debian/patches/pve/0047-savevm-async-fix-stuck-paused-vm-after-snapshot.patch
> @@ -0,0 +1,48 @@
> +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
> +From: Erik Fastermann <e.fastermann@proxmox.com>
> +Date: Thu, 11 Jun 2026 13:42:05 +0200
> +Subject: [PATCH] savevm-async: fix stuck paused vm after snapshot
> +
> +When creating a snapshot of a paused vm, the vm hung indefinitely in the
> +state "paused (finish-migrate)" and had to be restarted. This patch
> +fixes this by only transitioning the vm run state if the vm was
> +currently running.
> +
> +Signed-off-by: Erik Fastermann <e.fastermann@proxmox.com>
> +---
> + migration/savevm-async.c | 12 ++++++++----
> + 1 file changed, 8 insertions(+), 4 deletions(-)
> +
> +diff --git a/migration/savevm-async.c b/migration/savevm-async.c
> +index acd1a4de6e..153433f539 100644
> +--- a/migration/savevm-async.c
> ++++ b/migration/savevm-async.c
> +@@ -181,9 +181,11 @@ static void process_savevm_finalize(void *opaque)
> +     blk_set_aio_context(snap_state.target, qemu_get_aio_context(), NULL);
> + 
> +     snap_state.vm_needs_start = runstate_is_running();
> +-    ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
> +-    if (ret < 0) {
> +-        save_snapshot_error("vm_stop_force_state error %d", ret);
> ++    if (snap_state.vm_needs_start) {
> ++        ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);

It feels wrong to me to avoid going into the finish-migrate state, since
we do things like qemu_savevm_state_complete_precopy(),
qemu_savevm_state_cleanup() and save_snapshot_cleanup() below.

In migration/migration.c there is

        if (runstate_is_live(s->vm_old_state)) {
            if (!runstate_check(RUN_STATE_SHUTDOWN)) {
                vm_start();
            }
        } else {
            if (runstate_check(RUN_STATE_FINISH_MIGRATE)) {
                runstate_set(s->vm_old_state);
            }
        }

The old state is saved via runstate_get() in migration_stop_vm() before
stopping the VM. I think we should do the same.


> ++        if (ret < 0) {
> ++            save_snapshot_error("vm_stop_force_state error %d", ret);
> ++        }
> +     }
> + 
> +     if (!aborted) {
> +@@ -370,7 +372,9 @@ void qmp_savevm_start(const char *statefile, Error **errp)
> + 
> +     if (!statefile) {
> +         snap_state.vm_needs_start = runstate_is_running();

And for us, the place to store the old state is here.

> +-        vm_stop(RUN_STATE_SAVE_VM);
> ++        if (snap_state.vm_needs_start) {
> ++            vm_stop(RUN_STATE_SAVE_VM);
> ++        }
> +         snap_state.state = SAVE_STATE_COMPLETED;
> +         return;
> +     }
> +-- 
> +2.47.3
> +
> diff --git a/debian/patches/series b/debian/patches/series
> index 84c0664..6463a4a 100644
> --- a/debian/patches/series
> +++ b/debian/patches/series
> @@ -70,3 +70,4 @@ pve/0043-PVE-backup-get-device-info-allow-caller-to-specify-f.patch
>  pve/0044-PVE-backup-implement-backup-access-setup-and-teardow.patch
>  pve/0045-PVE-backup-prepare-for-the-switch-to-using-blockdev-.patch
>  pve/0046-savevm-async-reuse-migration-blocker-check-for-snaps.patch
> +pve/0047-savevm-async-fix-stuck-paused-vm-after-snapshot.patch





      reply	other threads:[~2026-08-26 13:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12  7:53 [RFC PATCH pve-qemu] savevm-async: fix stuck paused vm after snapshot Erik Fastermann
2026-08-26 13:30 ` Fiona Ebner [this message]

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=d052f289-1c33-4db7-814b-aa4664446666@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=e.fastermann@proxmox.com \
    --cc=pve-devel@lists.proxmox.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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal