[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/25] migration: Add helper to get target runstate
From: |
Fabiano Rosas |
Subject: |
[PULL 10/25] migration: Add helper to get target runstate |
Date: |
Fri, 10 Jan 2025 09:13:58 -0300 |
From: Peter Xu <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>
Message-Id: <20241206230838.1111496-2-peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/migration.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index df61ca4e93..969b03cdcd 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.35.3
- [PULL 00/25] Migration patches for 2025-01-10, Fabiano Rosas, 2025/01/10
- [PULL 01/25] migration/multifd: Fix compile error caused by page_size usage, Fabiano Rosas, 2025/01/10
- [PULL 02/25] migration/multifd: Further remove the SYNC on complete, Fabiano Rosas, 2025/01/10
- [PULL 03/25] migration/multifd: Allow to sync with sender threads only, Fabiano Rosas, 2025/01/10
- [PULL 04/25] migration/ram: Move RAM_SAVE_FLAG* into ram.h, Fabiano Rosas, 2025/01/10
- [PULL 05/25] migration/multifd: Unify RAM_SAVE_FLAG_MULTIFD_FLUSH messages, Fabiano Rosas, 2025/01/10
- [PULL 06/25] migration/multifd: Remove sync processing on postcopy, Fabiano Rosas, 2025/01/10
- [PULL 07/25] migration/multifd: Cleanup src flushes on condition check, Fabiano Rosas, 2025/01/10
- [PULL 08/25] migration/multifd: Document the reason to sync for save_setup(), Fabiano Rosas, 2025/01/10
- [PULL 09/25] migration/multifd: Fix compat with QEMU < 9.0, Fabiano Rosas, 2025/01/10
- [PULL 10/25] migration: Add helper to get target runstate,
Fabiano Rosas <=
- [PULL 11/25] qmp/cont: Only activate disks if migration completed, Fabiano Rosas, 2025/01/10
- [PULL 12/25] migration/block: Make late-block-active the default, Fabiano Rosas, 2025/01/10
- [PULL 13/25] migration/block: Apply late-block-active behavior to postcopy, Fabiano Rosas, 2025/01/10
- [PULL 14/25] migration/block: Fix possible race with block_inactive, Fabiano Rosas, 2025/01/10
- [PULL 15/25] migration/block: Rewrite disk activation, Fabiano Rosas, 2025/01/10
- [PULL 16/25] migration: Add more error handling to analyze-migration.py, Fabiano Rosas, 2025/01/10
- [PULL 17/25] migration: Remove unused argument in vmsd_desc_field_end, Fabiano Rosas, 2025/01/10
- [PULL 18/25] migration: Fix parsing of s390 stream, Fabiano Rosas, 2025/01/10
- [PULL 19/25] migration: Rename vmstate_info_nullptr, Fabiano Rosas, 2025/01/10
- [PULL 20/25] migration: Dump correct JSON format for nullptr replacement, Fabiano Rosas, 2025/01/10