]> git.proxmox.com Git - qemu-server.git/commitdiff
wait for vm scopes to be gone
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 19 Jun 2019 07:21:22 +0000 (09:21 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 19 Jun 2019 08:11:38 +0000 (10:11 +0200)
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 <w.bumiller@proxmox.com>
PVE/QemuServer.pm

index 341e0b0317491e812c5b18008993650e9dc99653..e8e1909e30933298cb2f174b2e7915853d8d7fd6 100644 (file)
@@ -5335,12 +5335,13 @@ sub vm_start {
 
        PVE::Storage::activate_volumes($storecfg, $vollist);
 
 
        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};
 
        my $cpuunits = defined($conf->{cpuunits}) ? $conf->{cpuunits}
                                                  : $defaults->{cpuunits};