From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu 3/3] async snapshot: keep track of savevm-end status
Date: Wed, 18 Nov 2026 13:21:49 +0100 [thread overview]
Message-ID: <20261118122359.123647-4-f.ebner@proxmox.com> (raw)
In-Reply-To: <20261118122359.123647-1-f.ebner@proxmox.com>
If a snapshot ends with an error, qemu-server had no way to detect
when it's safe to consider 'savevm-end' done. The result of
'query-savevm' only changes when the status is set to SAVE_STATE_DONE,
not reporting the 'bytes' value anymore, and qemu-server looked at
that. Keep track of the 'savevm-end' state and report it to allow
distinguishing between 'savevm-end' being done or still waiting for
the target file close in case of an error.
Checking for an already active 'savevm-end' invocation at the
beginning of qmp_savevm_end() fixes a crash: when a second
'savevm-end' QMP call came in, while a previous one was still sleeping
in target_close_wait, the following assertion would trigger:
> kvm: ../util/qemu-coroutine-sleep.c:77: qemu_co_sleep: \
> Assertion `prev == NULL' failed.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
migration/savevm-async.c | 13 +++++++++++++
qapi/migration.json | 6 +++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
index 3ab0bd4539..e9037173af 100644
--- a/migration/savevm-async.c
+++ b/migration/savevm-async.c
@@ -60,6 +60,7 @@ static struct SnapshotState {
Coroutine *co;
QemuCoSleep target_close_wait;
IOThread *iothread;
+ bool savevm_end_active;
} snap_state;
static bool savevm_aborted(void)
@@ -77,6 +78,8 @@ SaveVMInfo *qmp_query_savevm(Error **errp)
SaveVMInfo *info = g_malloc0(sizeof(*info));
struct SnapshotState *s = &snap_state;
+ info->savevm_end_active = s->savevm_end_active;
+
if (s->state != SAVE_STATE_DONE) {
info->has_bytes = true;
info->bytes = s->bs_pos;
@@ -498,6 +501,7 @@ static void coroutine_fn wait_for_close_co(void *opaque)
"qmp_savevm_end");
/* we cannot assume the snapshot finished in this case, so leave the
* state alone - caller has to figure something out */
+ snap_state.savevm_end_active = false;
return;
}
} else {
@@ -511,6 +515,8 @@ static void coroutine_fn wait_for_close_co(void *opaque)
snap_state.state = SAVE_STATE_DONE;
}
+ snap_state.savevm_end_active = false;
+
DPRINTF("savevm-end: cleanup done\n");
}
@@ -521,6 +527,13 @@ void qmp_savevm_end(Error **errp)
return;
}
+ if (snap_state.savevm_end_active) {
+ error_setg(errp, "savevm-end handler already running");
+ return;
+ }
+
+ snap_state.savevm_end_active = true;
+
Coroutine *wait_for_close = qemu_coroutine_create(wait_for_close_co, NULL);
if (snap_state.state == SAVE_STATE_ACTIVE) {
diff --git a/qapi/migration.json b/qapi/migration.json
index 0794a3a7a3..d7504a0d4d 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -354,11 +354,15 @@
#
# @bytes: total amount of data transfered
#
+# @savevm-end-active: Whether a @savevm-end handler is currently
+# active.
+#
# Since: 1.3
##
{ 'struct': 'SaveVMInfo',
'data': {'*status': 'str', '*error': 'str',
- '*total-time': 'int', '*bytes': 'int'} }
+ '*total-time': 'int', '*bytes': 'int',
+ 'savevm-end-active': 'bool'} }
##
# @query-savevm:
--
2.47.3
next prev parent reply other threads:[~2026-11-18 12:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 12:21 [PATCH-SERIES qemu-server/qemu 0/3] fix #8331: snapshot: fix regression with endless loop after error Fiona Ebner
2026-11-18 12:21 ` [PATCH qemu-server 1/3] " Fiona Ebner
2026-11-18 12:21 ` [PATCH qemu-server 2/3] snapshot: directly check for savevm-end status Fiona Ebner
2026-11-18 12:21 ` Fiona Ebner [this message]
2026-11-18 21:02 ` applied: [PATCH-SERIES qemu-server/qemu 0/3] fix #8331: snapshot: fix regression with endless loop after error Thomas Lamprecht
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=20261118122359.123647-4-f.ebner@proxmox.com \
--to=f.ebner@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 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.