public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server] fix #3577: prevent vms with pci passthrough to suspend to disk
@ 2022-06-21 14:07 Dominik Csapak
  2022-08-30  8:26 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Csapak @ 2022-06-21 14:07 UTC (permalink / raw)
  To: pve-devel

while it may work to suspend, resume will most likely not work, because
we do/can not save/restore the hardware state of the devices

instead, prevent the user from suspending the vm at all.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/API2/Qemu.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 99b426e..24d0f59 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -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);
 	    }
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-31  0:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 14:07 [pve-devel] [PATCH qemu-server] fix #3577: prevent vms with pci passthrough to suspend to disk Dominik Csapak
2022-08-30  8:26 ` [pve-devel] applied: " Thomas Lamprecht
2022-08-31  0:18   ` DERUMIER, Alexandre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal