Determine if VM needs to be started after finishing right before actually stopping the VM instead of at the beginning.
In qmp_savevm_start(), the only path stopping the VM returns right aftwards, so there is no need for the vm_start() handling after errors. The next commit will inline the remaining error handling and avoid the confusing naming of the 'restart' goto label. Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> --- migration/savevm-async.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/migration/savevm-async.c b/migration/savevm-async.c index 1e34c31e8b..72d8ed2739 100644 --- a/migration/savevm-async.c +++ b/migration/savevm-async.c @@ -178,6 +178,7 @@ static void process_savevm_finalize(void *opaque) */ blk_set_aio_context(snap_state.target, qemu_get_aio_context(), NULL); + snap_state.vm_needs_start = runstate_is_running(); ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); if (ret < 0) { save_snapshot_error("vm_stop_force_state error %d", ret); @@ -352,7 +353,6 @@ void qmp_savevm_start(const char *statefile, Error **errp) } /* initialize snapshot info */ - snap_state.vm_needs_start = runstate_is_running(); snap_state.bs_pos = 0; snap_state.total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); snap_state.blocker = NULL; @@ -364,6 +364,7 @@ void qmp_savevm_start(const char *statefile, Error **errp) } if (!statefile) { + snap_state.vm_needs_start = runstate_is_running(); vm_stop(RUN_STATE_SAVE_VM); snap_state.state = SAVE_STATE_COMPLETED; return; @@ -439,11 +440,6 @@ void qmp_savevm_start(const char *statefile, Error **errp) restart: save_snapshot_error("setup failed"); - - if (snap_state.vm_needs_start) { - vm_start(); - snap_state.vm_needs_start = false; - } } static void coroutine_fn wait_for_close_co(void *opaque) -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel