From 503308ed91d2b2ff83e6b4647f34f3954237de78 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 7 May 2018 12:09:10 +0200 Subject: [PATCH] start: fork before entering scope To avoid potential cleanup & post-start actions to cause unwanted processes (such as gpg-agent) to be started as part of the scope, as the enter_systemd_scope() function causes the current process to enter the scope. Signed-off-by: Wolfgang Bumiller --- PVE/QemuServer.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 015c725..0c63d6c 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4841,6 +4841,13 @@ sub vm_start { } $properties{timeout} = 10 if $statefile; # setting up the scope shoul be quick + my $run_qemu = sub { + PVE::Tools::run_fork sub { + PVE::Tools::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %properties); + run_command($cmd, %run_params); + }; + }; + if ($conf->{hugepages}) { my $code = sub { @@ -4850,11 +4857,7 @@ sub vm_start { PVE::QemuServer::Memory::hugepages_mount(); PVE::QemuServer::Memory::hugepages_allocate($hugepages_topology, $hugepages_host_topology); - eval { - PVE::Tools::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %properties); - run_command($cmd, %run_params); - }; - + eval { $run_qemu->() }; if (my $err = $@) { PVE::QemuServer::Memory::hugepages_reset($hugepages_host_topology); die $err; @@ -4865,10 +4868,7 @@ sub vm_start { eval { PVE::QemuServer::Memory::hugepages_update_locked($code); }; } else { - eval { - PVE::Tools::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %properties); - run_command($cmd, %run_params); - }; + eval { $run_qemu->() }; } if (my $err = $@) { -- 2.39.2