From: Pranav Tyagi <prtyagi@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,
Juraj Marcin <jmarcin@redhat.com>,
Prasad Pandit <ppandit@redhat.com>,
Pranav Tyagi <prtyagi@redhat.com>
Subject: [PATCH] migration: Fix blocking in POSTCOPY_DEVICE during package load
Date: Tue, 21 Apr 2026 10:52:27 +0530 [thread overview]
Message-ID: <20260421052227.8278-1-prtyagi@redhat.com> (raw)
The package_loaded event is not set in case MIG_RP_MSG_PONG does not
arrive on the source from the destination in the return path thread. The
migration thread would then be blocked waiting for package_loaded event
indefinitely in POSTCOPY_DEVICE state. Where as, in such a condition the
source VM can safely resume as the destination has not yet started. The
pong message can get lost in case of a network failure or destination
crash before sending the pong.
This patch uses the error detected in case of network failure or
destination crash to set the package_loaded event in the out path of the
return path thread. This will kick the migration thread out from
a condition of indefinitely waiting for the package_loaded event. The
migration thread then fails early and breaks from the migration loop to
resume the VM on the source side.
Fixes: 7b842fe354c6 ("migration: Introduce POSTCOPY_DEVICE state")
Signed-off-by: Pranav Tyagi <prtyagi@redhat.com>
---
migration/migration.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/migration/migration.c b/migration/migration.c
index 5c9aaa6e58..1656c1203c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2386,6 +2386,15 @@ out:
if (err) {
migrate_error_propagate(ms, err);
trace_source_return_path_thread_bad_end();
+ if (ms->state == MIGRATION_STATUS_POSTCOPY_DEVICE) {
+ /*
+ * Kick the migration thread if it gets stuck in
+ * POSTCOPY_DEVICE state waiting for
+ * postcopy_package_loaded_event. The event will never be
+ * set as MIG_RP_MSG_PONG from the destination is lost.
+ */
+ qemu_event_set(&ms->postcopy_package_loaded_event);
+ }
}
if (ms->state == MIGRATION_STATUS_POSTCOPY_RECOVER) {
@@ -3232,6 +3241,17 @@ static MigIterateState migration_iteration_run(MigrationState *s)
* package before actually completing.
*/
qemu_event_wait(&s->postcopy_package_loaded_event);
+ /*
+ * Check for errors in case the migration thread was stuck in
+ * POSTCOPY_DEVICE state waiting for the
+ * postcopy_package_loaded_event which was never set.
+ * If so, fail now and break out of the iteration.
+ */
+ if (migrate_has_error(s)) {
+ migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_DEVICE,
+ MIGRATION_STATUS_FAILING);
+ return MIG_ITERATE_BREAK;
+ }
migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_DEVICE,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
}
--
2.53.0
next reply other threads:[~2026-04-21 5:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 5:22 Pranav Tyagi [this message]
2026-04-21 21:25 ` [PATCH] migration: Fix blocking in POSTCOPY_DEVICE during package load Peter Xu
2026-04-22 8:49 ` Pranav Tyagi
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=20260421052227.8278-1-prtyagi@redhat.com \
--to=prtyagi@redhat.com \
--cc=farosas@suse.de \
--cc=jmarcin@redhat.com \
--cc=peterx@redhat.com \
--cc=ppandit@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.