[pve-devel] [PATCH pve-container 1/1] Add pre/post-restore hooks to CTs

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Sep 22 15:53:20 CEST 2022


On Thu, Sep 22, 2022 at 03:19:42PM +0200, Stefan Hanreich wrote:
> Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
> ---
>  src/PVE/API2/LXC.pm | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index 589f96f..3ecf5e5 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -376,6 +376,8 @@ __PACKAGE__->register_method({
>  	    eval {
>  		my $orig_mp_param; # only used if $restore
>  		if ($restore) {
> +		    PVE::GuestHelpers::exec_hookscript($old_conf, $vmid, 'pre-restore', 1);
> +
>  		    die "can't overwrite running container\n" if PVE::LXC::check_running($vmid);

I think this check should happen before the hook.

>  		    if ($archive ne '-') {
>  			my $orig_conf;
> @@ -502,6 +504,10 @@ __PACKAGE__->register_method({
>  
>  	    PVE::API2::LXC::Status->vm_start({ vmid => $vmid, node => $node })
>  		if $start_after_create;
> +
> +	    if ($restore) {
> +		PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-restore');
> +	    }
>  	};
>  
>  	my $workername = $restore ? 'vzrestore' : 'vzcreate';
> -- 
> 2.30.2





More information about the pve-devel mailing list