Skip to content

Commit

Permalink
migration: migration_stop_vm() helper
Browse files Browse the repository at this point in the history
Provide a helper for non-COLO use case of migration to stop a VM.  This
prepares for adding some downtime relevant tracepoints to migration, where
they may or may not apply to COLO.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231030163346.765724-5-peterx@redhat.com>
  • Loading branch information
xzpeter authored and Juan Quintela committed Nov 1, 2023
1 parent 3c80f14 commit 93bdf88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp)
return (a > b) - (a < b);
}

int migration_stop_vm(RunState state)
{
return vm_stop_force_state(state);
}

void migration_object_init(void)
{
/* This can only be called once. */
Expand Down Expand Up @@ -2169,7 +2174,7 @@ static int postcopy_start(MigrationState *ms, Error **errp)

qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
global_state_store();
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE);
if (ret < 0) {
goto fail;
}
Expand Down Expand Up @@ -2371,7 +2376,7 @@ static int migration_completion_precopy(MigrationState *s,
s->vm_old_state = runstate_get();
global_state_store();

ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE);
trace_migration_completion_vm_stop(ret);
if (ret < 0) {
goto out_unlock;
Expand Down Expand Up @@ -3222,7 +3227,7 @@ static void *bg_migration_thread(void *opaque)

global_state_store();
/* Forcibly stop VM before saving state of vCPUs and devices */
if (vm_stop_force_state(RUN_STATE_PAUSED)) {
if (migration_stop_vm(RUN_STATE_PAUSED)) {
goto fail;
}
/*
Expand Down
2 changes: 2 additions & 0 deletions migration/migration.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,4 +544,6 @@ void migration_rp_wait(MigrationState *s);
*/
void migration_rp_kick(MigrationState *s);

int migration_stop_vm(RunState state);

#endif

0 comments on commit 93bdf88

Please sign in to comment.