The function checks for resources that cannot be migrated, snapshoted, or suspended.
Signed-off-by: Markus Frank <m.fr...@proxmox.com> --- changes v11: * this patch is new to v11 PVE/API2/Qemu.pm | 5 ++++- PVE/QemuMigrate.pm | 2 +- PVE/QemuServer.pm | 23 ++++++++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 2a1d4d7..8f36cf8 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -4504,7 +4504,7 @@ __PACKAGE__->register_method({ $res->{running} = PVE::QemuServer::check_running($vmid) ? 1:0; my ($local_resources, $mapped_resources, $missing_mappings_by_node) = - PVE::QemuServer::check_local_resources($vmconf, 1); + PVE::QemuServer::check_local_resources($vmconf, $res->{running}, 1); delete $missing_mappings_by_node->{$localnode}; my $vga = PVE::QemuServer::parse_vga($vmconf->{vga}); @@ -5192,6 +5192,9 @@ __PACKAGE__->register_method({ die "unable to use snapshot name 'pending' (reserved name)\n" if lc($snapname) eq 'pending'; + my $vmconf = PVE::QemuConfig->load_config($vmid); + PVE::QemuServer::check_non_migratable_resources($vmconf, $param->{vmstate}, 0); + my $realcmd = sub { PVE::Cluster::log_msg('info', $authuser, "snapshot VM $vmid: $snapname"); PVE::QemuConfig->snapshot_create($vmid, $snapname, $param->{vmstate}, diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 33d5b2d..27043c1 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -232,7 +232,7 @@ sub prepare { $self->{vm_was_paused} = 1 if PVE::QemuServer::vm_is_paused($vmid, 0); } - my ($loc_res, $mapped_res, $missing_mappings_by_node) = PVE::QemuServer::check_local_resources($conf, 1); + my ($loc_res, $mapped_res, $missing_mappings_by_node) = PVE::QemuServer::check_local_resources($conf, $running, 1); my $blocking_resources = []; for my $res ($loc_res->@*) { if (!grep($res, $mapped_res->@*)) { diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 31a7ee9..9f342bf 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2563,13 +2563,32 @@ sub config_list { return $res; } +sub check_non_migratable_resources { + my ($conf, $state, $noerr) = @_; + + my @non_migr_res = (); + if ($state && $conf->{amd_sev}) { + push @non_migr_res, "amd_sev"; + } + + if (scalar @non_migr_res && !$noerr) { + die "Cannot live-migrate, snapshot (with RAM), or hibernate a VM with:" + ." @non_migr_res\n"; + } + + return @non_migr_res; +} + # test if VM uses local resources (to prevent migration) sub check_local_resources { - my ($conf, $noerr) = @_; + my ($conf, $state, $noerr) = @_; my @loc_res = (); my $mapped_res = []; + my @non_migr_res = check_non_migratable_resources($conf, $state, $noerr); + push(@loc_res, @non_migr_res); + my $nodelist = PVE::Cluster::get_nodelist(); my $pci_map = PVE::Mapping::PCI::config(); my $usb_map = PVE::Mapping::USB::config(); @@ -6362,6 +6381,8 @@ sub vm_suspend { die "cannot suspend to disk during backup\n" if $is_backing_up && $includestate; + check_non_migratable_resources($conf, $includestate, 0); + if ($includestate) { $conf->{lock} = 'suspending'; my $date = strftime("%Y-%m-%d", localtime(time())); -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel