@@ -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);
@@ -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)
@@ -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;
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(-)