fix #3577: prevent suspension for VMs with pci passthrough

Prevent the user from suspending the vm at all, as while suspension
itself may finish, the saved state is incomplete as we can neither
save nor restore PCIe device state in any generic fashion, so
resuming will almost certainly break.

The single case when it could work is when the guest OS didn't uses
the passed through device at all, so there's no state, but that's
really odd (as why bother passing through then), and the user should
rather remove the hostpci entry in that case.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ T: reword commit message slightly ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2022-06-21 16:07:04 +02:00 committed by Thomas Lamprecht
parent 50164179db
commit 227a298f7f

View File

@ -2977,10 +2977,17 @@ __PACKAGE__->register_method({
# early check for storage permission, for better user feedback
if ($todisk) {
$rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.Disk']);
my $conf = PVE::QemuConfig->load_config($vmid);
# check for hostpci devices (suspend will maybe work, resume won't),
# so prevent users from suspending in the first place
for my $key (keys %$conf) {
next if $key !~ /^hostpci\d+/;
die "Cannot suspend VM to disk with assigned PCI devices\n";
}
if (!$statestorage) {
# get statestorage from config if none is given
my $conf = PVE::QemuConfig->load_config($vmid);
my $storecfg = PVE::Storage::config();
$statestorage = PVE::QemuServer::find_vmstate_storage($conf, $storecfg);
}