[pve-devel] [PATCH qemu-server v4 4/6] re-check if VM is running and PID for KILL after timeout

Daniel Tschlatscher d.tschlatscher at proxmox.com
Thu Jan 5 11:08:35 CET 2023


This avoids accidentally killing a potentially completely unrelated
process that was spawned in an edge case between the last check in the
timeout loop and the kill command.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher at proxmox.com>
---
Changes from v3:
* New patch

 PVE/QemuServer.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 549d666..e14b76e 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6241,7 +6241,7 @@ sub _do_vm_stop {
 
     if ($count >= $timeout) {
 	warn "VM still running - terminating now with SIGKILL\n";
-	kill 9, $pid;
+	kill(9, $pid) if check_running($vmid, $nocheck) eq $pid;
 	sleep 1;
     }
 
-- 
2.30.2






More information about the pve-devel mailing list