From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: peterx@redhat.com, qemu-block@nongnu.org,
"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Andrey Drobyshev" <andrey.drobyshev@virtuozzo.com>,
"Eric Blake" <eblake@redhat.com>,
"Dr . David Alan Gilbert" <dave@treblig.org>,
"Kevin Wolf" <kwolf@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>
Subject: [PATCH v2 1/6] migration: Add helper to get target runstate
Date: Fri, 6 Dec 2024 18:08:33 -0500 [thread overview]
Message-ID: <20241206230838.1111496-2-peterx@redhat.com> (raw)
In-Reply-To: <20241206230838.1111496-1-peterx@redhat.com>
In 99% cases, after QEMU migrates to dest host, it tries to detect the
target VM runstate using global_state_get_runstate().
There's one outlier so far which is Xen that won't send global state.
That's the major reason why global_state_received() check was always there
together with global_state_get_runstate().
However it's utterly confusing why global_state_received() has anything to
do with "let's start VM or not".
Provide a helper to explain it, then we have an unified entry for getting
the target dest QEMU runstate after migration.
Suggested-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/migration.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 8c5bd0a75c..d2a6b939cf 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -135,6 +135,21 @@ static bool migration_needs_multiple_sockets(void)
return migrate_multifd() || migrate_postcopy_preempt();
}
+static RunState migration_get_target_runstate(void)
+{
+ /*
+ * When the global state is not migrated, it means we don't know the
+ * runstate of the src QEMU. We don't have much choice but assuming
+ * the VM is running. NOTE: this is pretty rare case, so far only Xen
+ * uses it.
+ */
+ if (!global_state_received()) {
+ return RUN_STATE_RUNNING;
+ }
+
+ return global_state_get_runstate();
+}
+
static bool transport_supports_multi_channels(MigrationAddress *addr)
{
if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
@@ -735,8 +750,7 @@ static void process_incoming_migration_bh(void *opaque)
* unless we really are starting the VM.
*/
if (!migrate_late_block_activate() ||
- (autostart && (!global_state_received() ||
- runstate_is_live(global_state_get_runstate())))) {
+ (autostart && runstate_is_live(migration_get_target_runstate()))) {
/* Make sure all file formats throw away their mutable metadata.
* If we get an error here, just don't restart the VM yet. */
bdrv_activate_all(&local_err);
@@ -759,8 +773,7 @@ static void process_incoming_migration_bh(void *opaque)
dirty_bitmap_mig_before_vm_start();
- if (!global_state_received() ||
- runstate_is_live(global_state_get_runstate())) {
+ if (runstate_is_live(migration_get_target_runstate())) {
if (autostart) {
vm_start();
} else {
--
2.47.0
next prev parent reply other threads:[~2024-12-06 23:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 23:08 [PATCH v2 0/6] migration/block: disk activation rewrite Peter Xu
2024-12-06 23:08 ` Peter Xu [this message]
2024-12-06 23:08 ` [PATCH v2 2/6] qmp/cont: Only activate disks if migration completed Peter Xu
2024-12-16 15:10 ` Fabiano Rosas
2024-12-06 23:08 ` [PATCH v2 3/6] migration/block: Make late-block-active the default Peter Xu
2024-12-16 15:16 ` Fabiano Rosas
2024-12-06 23:08 ` [PATCH v2 4/6] migration/block: Apply late-block-active behavior to postcopy Peter Xu
2024-12-16 15:17 ` Fabiano Rosas
2024-12-06 23:08 ` [PATCH v2 5/6] migration/block: Fix possible race with block_inactive Peter Xu
2024-12-16 15:18 ` Fabiano Rosas
2024-12-06 23:08 ` [PATCH v2 6/6] migration/block: Rewrite disk activation Peter Xu
2024-12-16 15:58 ` Fabiano Rosas
2024-12-16 18:33 ` Peter Xu
2024-12-17 15:26 ` [PATCH v2 0/6] migration/block: disk activation rewrite Fabiano Rosas
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=20241206230838.1111496-2-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=berrange@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=farosas@suse.de \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@yandex-team.ru \
/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;
as well as URLs for NNTP newsgroup(s).