[pve-devel] [PATCH qemu-server] start: always stop an existing $vmid.scope

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Feb 16 12:44:58 CET 2018


Checking for the cgroup directory is a kind of time-of-check
time-of-use race condition stop-mode backups seem to
occasionally run into on some systems.

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 PVE/QemuServer.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 1607932..a5cb310 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4715,10 +4715,11 @@ sub vm_start {
 
 	PVE::Storage::activate_volumes($storecfg, $vollist);
 
-	if (!check_running($vmid, 1) && -d "/sys/fs/cgroup/systemd/qemu.slice/$vmid.scope") {
-	    my $cmd = [];
-	    push @$cmd, '/bin/systemctl', 'stop', "$vmid.scope";
-	    eval  { run_command($cmd); };
+	if (!check_running($vmid, 1)) {
+	    eval {
+		run_command(['/bin/systemctl', 'stop', "$vmid.scope"],
+		    outfunc => sub {}, errfunc => sub {});
+	    };
 	}
 
 	my $cpuunits = defined($conf->{cpuunits}) ? $conf->{cpuunits}
-- 
2.11.0





More information about the pve-devel mailing list