]> git.proxmox.com Git - pve-container.git/commitdiff
Fix pct skiplock
authorAlwin Antreich <a.antreich@proxmox.com>
Wed, 14 Mar 2018 12:51:55 +0000 (13:51 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 14 Mar 2018 13:00:37 +0000 (14:00 +0100)
The method vm_start sets an environment variable that is not picked up
anymore by systemd. This patch removes the environment variable and
introduces a skiplock file that is picked up by the
lxc-pve-prestart-hook.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
src/PVE/LXC.pm
src/lxc-pve-prestart-hook

index 7adbcd1e3329cdb3e6534ab5864bafb2ac72e77c..bec47ddf8b7f861871b43ac7d2336aa8c8919d0f 100644 (file)
@@ -1545,11 +1545,20 @@ sub vm_start {
 
     update_lxc_config($vmid, $conf);
 
-    local $ENV{PVE_SKIPLOCK}=1 if $skiplock;
+    my $skiplock_flag_fn = "/run/lxc/skiplock-$vmid";
+
+    if ($skiplock) {
+       open(my $fh, '>', $skiplock_flag_fn) || die "failed to open $skiplock_flag_fn for writing: $!\n";
+       close($fh);
+    }
 
     my $cmd = ['systemctl', 'start', "pve-container\@$vmid"];
 
-    PVE::Tools::run_command($cmd);
+    eval { PVE::Tools::run_command($cmd); };
+    if (my $err = $@) {
+       unlink $skiplock_flag_fn;
+       die $err if $err;
+    }
 
     return;
 }
index fd2942323b565ae3a94a7447964a5c5e41faf49d..61a8ef33c48c11e7088c60d41f780dc96af6257b 100755 (executable)
@@ -57,13 +57,16 @@ __PACKAGE__->register_method ({
        return undef if $param->{name} !~ m/^\d+$/;
 
        my $vmid = $param->{name};
+       my $skiplock_flag_fn = "/run/lxc/skiplock-$vmid";
+       my $skiplock = 1 if -e $skiplock_flag_fn;
+       unlink $skiplock_flag_fn if $skiplock;
 
        PVE::Cluster::check_cfs_quorum(); # only start if we have quorum
 
        return undef if ! -f PVE::LXC::Config->config_file($vmid);
 
        my $conf = PVE::LXC::Config->load_config($vmid);
-       if (!$ENV{PVE_SKIPLOCK} && !PVE::LXC::Config->has_lock($conf, 'mounted')) {
+       if (!$skiplock && !PVE::LXC::Config->has_lock($conf, 'mounted')) {
            PVE::LXC::Config->check_lock($conf);
        }