The call get_current_qemu_machine() already depends on the virtual
machine running, so not being able to obtain the PID is very
unexpected. Quietly not including the running CPU in the snapshot can
lead to not being able to restore the snapshot later, so die early
instead.

Signed-off-by: Fiona Ebner <[email protected]>
---

New in v3.

 src/PVE/QemuConfig.pm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/PVE/QemuConfig.pm b/src/PVE/QemuConfig.pm
index e3ba240e..33cac3be 100644
--- a/src/PVE/QemuConfig.pm
+++ b/src/PVE/QemuConfig.pm
@@ -243,10 +243,9 @@ sub __snapshot_save_vmstate {
     my $runningmachine = 
PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
 
     # get current QEMU -cpu argument to ensure consistency of custom CPU models
-    my $runningcpu;
-    if (my $pid = PVE::QemuServer::Helpers::vm_running_locally($vmid)) {
-        $runningcpu = 
PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid);
-    }
+    my $pid = PVE::QemuServer::Helpers::vm_running_locally($vmid)
+        or die "cannot obtain PID for VM $vmid!\n";
+    my $runningcpu = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid);
 
     if (!$suspend) {
         $conf = $conf->{snapshots}->{$snapname};
-- 
2.47.2



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to