From 4f8cfa190abe85c9db0199743668024b09a3727b Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 19 Jun 2019 09:21:22 +0200 Subject: [PATCH] wait for vm scopes to be gone This should help with the rare case where stop mode backups fail to restart due to the $vmid.scope not being completely gone when we want to restart. This queries systemd via dbus, and if the scope is still there, awaits a UnitRemoved signal for the scope from dbus. For now with a 5 second timeout... (given that the processes are already gone and it's really just waiting for systemd to wake up, this should be plenty...) Signed-off-by: Wolfgang Bumiller --- PVE/QemuServer.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 341e0b0..e8e1909 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -5335,12 +5335,13 @@ sub vm_start { PVE::Storage::activate_volumes($storecfg, $vollist); - if (-d "/sys/fs/cgroup/systemd/qemu.slice/$vmid.scope") { - eval { - run_command(['/bin/systemctl', 'stop', "$vmid.scope"], - outfunc => sub {}, errfunc => sub {}); - }; - } + eval { + run_command(['/bin/systemctl', 'stop', "$vmid.scope"], + outfunc => sub {}, errfunc => sub {}); + }; + # Issues with the above 'stop' not being fully completed are extremely rare, a very low + # timeout should be more than enough here... + PVE::Systemd::wait_for_unit_removed("$vmid.scope", 5); my $cpuunits = defined($conf->{cpuunits}) ? $conf->{cpuunits} : $defaults->{cpuunits}; -- 2.39.2