When creating a snapshot of the VM state for hibernation, the VM must not be started again if the snapshot operation was completed successfully. The VM should remain stopped, so that the QMP 'quit' is issued without further activity from the VM.
The 'skip-vm-start' parameter for 'savevm-start' is available since QEMU version 11.0.1, so version-guard it. Signed-off-by: Fiona Ebner <[email protected]> --- src/PVE/QemuServer/RunState.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PVE/QemuServer/RunState.pm b/src/PVE/QemuServer/RunState.pm index 2d98e6bb..157cd1a8 100644 --- a/src/PVE/QemuServer/RunState.pm +++ b/src/PVE/QemuServer/RunState.pm @@ -2,6 +2,7 @@ package PVE::QemuServer::RunState; use v5.36; +use JSON qw(); use POSIX qw(strftime); use PVE::Cluster; @@ -13,6 +14,7 @@ use PVE::QemuConfig; use PVE::QemuMigrate::Helpers; use PVE::QemuServer::Monitor qw(mon_cmd); use PVE::QemuServer::Network; +use PVE::QemuServer::QMPHelpers; # note: if using the statestorage parameter, the caller has to check privileges sub vm_suspend($vmid, $skiplock = undef, $includestate = undef, $statestorage = undef) { @@ -72,7 +74,11 @@ sub vm_suspend($vmid, $skiplock = undef, $includestate = undef, $statestorage = eval { PVE::QemuMigrate::Helpers::set_migration_caps($vmid, 1); - mon_cmd($vmid, "savevm-start", statefile => $path); + my $savevm_start_params = { statefile => $path }; + if (PVE::QemuServer::QMPHelpers::runs_at_least_qemu_version($vmid, 11, 0, 1)) { + $savevm_start_params->{'skip-vm-start'} = JSON::true; + } + mon_cmd($vmid, "savevm-start", $savevm_start_params->%*); for (;;) { my $state = mon_cmd($vmid, "query-savevm"); if (!$state->{status}) { -- 2.47.3
