[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 04/29] migration: Return the saved state from global_state_sto
|
From: |
Fabiano Rosas |
|
Subject: |
[PATCH v2 04/29] migration: Return the saved state from global_state_store |
|
Date: |
Mon, 23 Oct 2023 17:35:43 -0300 |
There is a pattern of calling runstate_get() to store the current
runstate and calling global_state_store() to save the current runstate
for migration. Since global_state_store() also calls runstate_get(),
make it return the runstate instead.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
include/migration/global_state.h | 2 +-
migration/global_state.c | 7 +++++--
migration/migration.c | 6 ++----
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/migration/global_state.h b/include/migration/global_state.h
index d7c2cd3216..e268dc1f18 100644
--- a/include/migration/global_state.h
+++ b/include/migration/global_state.h
@@ -16,7 +16,7 @@
#include "qapi/qapi-types-run-state.h"
void register_global_state(void);
-void global_state_store(void);
+RunState global_state_store(void);
void global_state_store_running(void);
bool global_state_received(void);
RunState global_state_get_runstate(void);
diff --git a/migration/global_state.c b/migration/global_state.c
index 4e2a9d8ec0..d094af6198 100644
--- a/migration/global_state.c
+++ b/migration/global_state.c
@@ -37,9 +37,12 @@ static void global_state_do_store(RunState state)
state_str, '\0');
}
-void global_state_store(void)
+RunState global_state_store(void)
{
- global_state_do_store(runstate_get());
+ RunState r = runstate_get();
+
+ global_state_do_store(r);
+ return r;
}
void global_state_store_running(void)
diff --git a/migration/migration.c b/migration/migration.c
index 67547eb6a1..0c23117369 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2344,8 +2344,7 @@ static int migration_completion_precopy(MigrationState *s,
s->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
- s->vm_old_state = runstate_get();
- global_state_store();
+ s->vm_old_state = global_state_store();
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
trace_migration_completion_vm_stop(ret);
@@ -3201,9 +3200,8 @@ static void *bg_migration_thread(void *opaque)
* transition in vm_stop_force_state() we need to wakeup it up.
*/
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
- s->vm_old_state = runstate_get();
+ s->vm_old_state = global_state_store();
- global_state_store();
/* Forcibly stop VM before saving state of vCPUs and devices */
if (vm_stop_force_state(RUN_STATE_PAUSED)) {
goto fail;
--
2.35.3
- [PATCH v2 00/29] migration: File based migration with multifd and fixed-ram, Fabiano Rosas, 2023/10/23
- [PATCH v2 01/29] tests/qtest: migration events, Fabiano Rosas, 2023/10/23
- [PATCH v2 03/29] tests/qtest: Allow waiting for migration events, Fabiano Rosas, 2023/10/23
- [PATCH v2 02/29] tests/qtest: Move QTestMigrationState to libqtest, Fabiano Rosas, 2023/10/23
- [PATCH v2 04/29] migration: Return the saved state from global_state_store,
Fabiano Rosas <=
- [PATCH v2 05/29] migration: Introduce global_state_store_once, Fabiano Rosas, 2023/10/23
- [PATCH v2 06/29] migration: Add auto-pause capability, Fabiano Rosas, 2023/10/23
- Re: [PATCH v2 06/29] migration: Add auto-pause capability, Daniel P . Berrangé, 2023/10/25