[pve-devel] [PATCH v2 guest-common 07/28] snapshot_foreach_volume: Allow different volume selections

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Feb 25 12:32:28 CET 2020


see previous patch

On February 24, 2020 1:43 pm, Fabian Ebner wrote:
> by introducing a parameter $opts, which should contain
> 'include_<TYPE>'-flags. Also added @param and removed the
> '__'-prefix for future use from outside the module.
> 
> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
> ---
>  PVE/AbstractConfig.pm | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/PVE/AbstractConfig.pm b/PVE/AbstractConfig.pm
> index 5c449f6..9ce3d12 100644
> --- a/PVE/AbstractConfig.pm
> +++ b/PVE/AbstractConfig.pm
> @@ -501,9 +501,12 @@ sub __snapshot_rollback_get_unused {
>      die "abstract method - implement me\n";
>  }
>  
> -# Iterate over all configured volumes, calling $func for each key/value pair.
> -sub __snapshot_foreach_volume {
> -    my ($class, $conf, $func) = @_;
> +# Iterate over all configured volumes, calling $func for each key/value pair
> +# with additional parameters @param.
> +# By default unused volumes as well as special volumes like vmstate are excluded.
> +# They can be included in the iteration by setting $opts->{include_TYPE}
> +sub snapshot_foreach_volume {
> +    my ($class, $conf, $opts, $func, @param) = @_;
>  
>      die "abstract method - implement me\n";
>  }
> @@ -653,7 +656,7 @@ sub snapshot_create {
>  
>  	$class->__snapshot_create_vol_snapshots_hook($vmid, $snap, $running, "before");
>  
> -	$class->__snapshot_foreach_volume($snap, sub {
> +	$class->snapshot_foreach_volume($snap, undef, sub {
>  	    my ($vs, $volume) = @_;
>  
>  	    $class->__snapshot_create_vol_snapshot($vmid, $vs, $volume, $snapname);
> @@ -745,7 +748,7 @@ sub snapshot_delete {
>      };
>  
>      # now remove all volume snapshots
> -    $class->__snapshot_foreach_volume($snap, sub {
> +    $class->snapshot_foreach_volume($snap, undef, sub {
>  	my ($vs, $volume) = @_;
>  
>  	return if $snapname eq 'vzdump' && $vs ne 'rootfs' && !$volume->{backup};
> @@ -819,7 +822,7 @@ sub snapshot_rollback {
>      
>      my $snap = &$get_snapshot_config();
>  
> -    $class->__snapshot_foreach_volume($snap, sub {
> +    $class->snapshot_foreach_volume($snap, undef, sub {
>  	my ($vs, $volume) = @_;
>  
>  	$class->__snapshot_rollback_vol_possible($volume, $snapname);
> @@ -872,7 +875,7 @@ sub snapshot_rollback {
>  
>      $class->lock_config($vmid, $updatefn);
>  
> -    $class->__snapshot_foreach_volume($snap, sub {
> +    $class->snapshot_foreach_volume($snap, undef, sub {
>  	my ($vs, $volume) = @_;
>  
>  	$class->__snapshot_rollback_vol_rollback($volume, $snapname);
> -- 
> 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