From: Wolfgang Bumiller Date: Thu, 28 Jul 2016 14:23:19 +0000 (+0200) Subject: don't let lxc handle container reboots directly X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=fbeeb88f6ad4ee1080a45122010ed342f1868fb0;p=pve-container.git don't let lxc handle container reboots directly LXC doesn't reload the configuration on reboot causing hotplugged changes to not be persistent across container-side reboots. Instead, let the post-stop hook return false so that lxc stops while starting up a new instance in the background with the updated config. --- diff --git a/src/lxc-pve-poststop-hook b/src/lxc-pve-poststop-hook index 20569b2..b8524cc 100755 --- a/src/lxc-pve-poststop-hook +++ b/src/lxc-pve-poststop-hook @@ -72,6 +72,27 @@ __PACKAGE__->register_method ({ PVE::Network::veth_delete("veth${vmid}i$ind"); } + my $target = $ENV{LXC_TARGET}; + if ($target && $target eq 'reboot') { + # in order to make sure hot-plugged config changes aren't reverted + # to what the monitor initially loaded we need to stop the container + # and restart it + local $SIG{HUP} = 'IGNORE'; + my $pid = fork(); + die "fork failed during container reboot: $!\n" if !defined($pid); + if (!$pid) { + POSIX::setsid(); + close STDIN; + close STDOUT; + close STDERR; + PVE::LXC::update_lxc_config($vmid, $conf); + exec {'lxc-start'} 'lxc-start', '-n', $vmid + or POSIX::_exit(-1); + } + # cause lxc to stop instead of rebooting + POSIX::_exit(1); + } + return undef; }});