migrate: keep VM paused after migration if it was before

Also cannot issue a guest agent command in that case.

Reported in the community forum:
https://forum.proxmox.com/threads/106618

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2022-03-18 08:51:23 +01:00 committed by Thomas Lamprecht
parent d18b5d90ee
commit a183576e30

View File

@ -158,6 +158,8 @@ sub prepare {
$self->{forcecpu} = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid);
}
}
$self->{vm_was_paused} = 1 if PVE::QemuServer::vm_is_paused($vmid);
}
my $loc_res = PVE::QemuServer::check_local_resources($conf, 1);
@ -1146,6 +1148,7 @@ sub phase3_cleanup {
}
}
if (!$self->{vm_was_paused}) {
# config moved and nbd server stopped - now we can resume vm on target
if ($tunnel && $tunnel->{version} && $tunnel->{version} >= 1) {
eval {
@ -1168,11 +1171,16 @@ sub phase3_cleanup {
}
}
if ($self->{storage_migration} && PVE::QemuServer::parse_guest_agent($conf)->{fstrim_cloned_disks} && $self->{running}) {
if (
$self->{storage_migration}
&& PVE::QemuServer::parse_guest_agent($conf)->{fstrim_cloned_disks}
&& $self->{running}
) {
my $cmd = [@{$self->{rem_ssh}}, 'qm', 'guest', 'cmd', $vmid, 'fstrim'];
eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) };
}
}
}
# close tunnel on successful migration, on error phase2_cleanup closed it
if ($tunnel) {