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.antre...@proxmox.com> --- note: after discussion with Fabian, I removed the ENV variable. But I left the path of the skiplock file because we use it on other places in the code too. Though, I added a cleanup step if the container start fails. src/PVE/LXC.pm | 13 +++++++++++-- src/lxc-pve-prestart-hook | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 7adbcd1..acb5cfd 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -1545,11 +1545,20 @@ sub vm_start { update_lxc_config($vmid, $conf); - local $ENV{PVE_SKIPLOCK}=1 if $skiplock; + my $skiplock_flag_fn = "/var/lib/lxc/$vmid/skiplock"; + + 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 if -e $skiplock_flag_fn; + die $err if $err; + } return; } diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook index fd29423..eba23ee 100755 --- a/src/lxc-pve-prestart-hook +++ b/src/lxc-pve-prestart-hook @@ -57,13 +57,16 @@ __PACKAGE__->register_method ({ return undef if $param->{name} !~ m/^\d+$/; my $vmid = $param->{name}; + my $skiplock_flag_fn = "/var/lib/lxc/$vmid/skiplock"; + my $skiplock = 1 if -e $skiplock_flag_fn; + unlink $skiplock_flag_fn if -e $skiplock_flag_fn; 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); } -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel