[pve-devel] [PATCH v2 container 4/5] apply pending changes in lxc prestart hook

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Nov 19 16:20:07 CET 2019


On November 19, 2019 3:53 pm, Oguz Bektas wrote:
> this allows pending changes to be applied when a reboot is issued inside
> the container.
> 
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
>  src/lxc-pve-prestart-hook | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook
> index c0965ab..516217f 100755
> --- a/src/lxc-pve-prestart-hook
> +++ b/src/lxc-pve-prestart-hook
> @@ -29,6 +29,15 @@ PVE::LXC::Tools::lxc_hook('pre-start', 'lxc', sub {
>      return undef if ! -f PVE::LXC::Config->config_file($vmid);
>  
>      my $conf = PVE::LXC::Config->load_config($vmid);
> +
> +    # apply pending changes if present
> +    if ($conf->{pending}) {
> +	my @pending_delete = PVE::Tools::split_list($conf->{pending}->{delete});
> +	PVE::LXC::Config->update_pct_config($vmid, $conf, 0, $conf->{pending}, \@pending_delete);
> +	PVE::LXC::update_lxc_config($vmid, $conf);
> +	$conf = PVE::LXC::Config->load_config($vmid); # just to be sure
> +    }
> +

why is this so different from the code in PVE::LXC::vm_start, and isn't 
the copy there redundant if we include this here (since a vm_start always 
triggers this hook)?

>      if (!$skiplock && !PVE::LXC::Config->has_lock($conf, 'mounted')) {
>  	PVE::LXC::Config->check_lock($conf);
>      }
> -- 
> 2.20.1
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 




More information about the pve-devel mailing list