[pve-devel] [PATCH v6 storage] Optionally allow blockdev in abs_filesystem_path

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Mar 15 10:25:54 CET 2021


On March 9, 2021 11:43 am, Dominic Jäger wrote:
> This is required to import from LVM storages
> 
> Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
> ---
> v5->v6: unchanged
> 
>  PVE/Storage.pm | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 8ee2c92..7c2e24e 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -609,7 +609,7 @@ sub path {
>  }
>  
>  sub abs_filesystem_path {
> -    my ($cfg, $volid) = @_;
> +    my ($cfg, $volid, $allowBlockdev) = @_;

that's not how we name perl variables..

>  
>      my $path;
>      if (parse_volume_id ($volid, 1)) {
> @@ -623,8 +623,11 @@ sub abs_filesystem_path {
>  	    }
>  	}
>      }
> -
> -    die "can't find file '$volid'\n" if !($path && -f $path);
> +    if ($allowBlockdev) {
> +	die "can't find file '$volid'\n" if !($path && (-f $path || -b $path));
> +    } else {
> +	die "can't find file '$volid'\n" if !($path && -f $path);
> +    }

this could easily still be a single if:

    die "can't find file '$volid'\n"
      if !($path && -f $path) && !($path && $allow_block_dev && -b $path);

or some other transformation of the condition, like

  if !$path || !(-f $path || ($allow_block_dev && -b $path))

or

  if !($path && (-f $path || ($allow_block_dev && -b $path)))

>  
>      return $path;
>  }
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 





More information about the pve-devel mailing list