[pve-devel] applied: [PATCH container] apply pending changes in lxc poststop hook

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Nov 21 17:52:42 CET 2019


On 11/21/19 5:48 PM, Oguz Bektas wrote:
> apply pending changes after container is stopped (via API or systemctl), and
> update lxc config.
> 
> also affects reboots from inside the container. (but in that case we don't try
> to update_lxc_config again if pending changes were already applied and lxc config
> was updated)
> 
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
>  src/lxc-pve-poststop-hook | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc-pve-poststop-hook b/src/lxc-pve-poststop-hook
> index 19d0b52..64fe54d 100755
> --- a/src/lxc-pve-poststop-hook
> +++ b/src/lxc-pve-poststop-hook
> @@ -38,6 +38,14 @@ PVE::LXC::Tools::lxc_hook('post-stop', 'lxc', sub {
>  	PVE::Network::veth_delete("veth${vmid}i$ind");
>      }
>  
> +    my $config_updated = 0;
> +    if ($conf->{pending}) {
> +	PVE::LXC::Config->vmconfig_apply_pending($vmid, $conf, $storage_cfg);
> +	PVE::LXC::update_lxc_config($vmid, $conf);
> +	$config_updated = 1;
> +    }
> +
> +
>      my $target = $vars->{TARGET};
>      if ($target && $target eq 'reboot') {
>  	# In order to make sure hot-plugged config changes aren't reverted
> @@ -47,7 +55,7 @@ PVE::LXC::Tools::lxc_hook('post-stop', 'lxc', sub {
>  	# task, note that we must not block because we're part of the
>  	# service cgroup systemd waits for to die before issuing the new
>  	# lxc-start command.
> -	PVE::LXC::update_lxc_config($vmid, $conf);
> +	PVE::LXC::update_lxc_config($vmid, $conf) if !$config_updated;
>  	# Tell the post-stop hook we want to be restarted.
>  	open(my $fh, '>', "/var/lib/lxc/$vmid/reboot")
>  	    or die "failed to create reboot trigger file: $!\n";
> 

applied, thanks!




More information about the pve-devel mailing list