[pve-devel] [PATCH v2 manager 2/3] vzdump: handle pigz property string

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Feb 7 16:49:53 CET 2020


On 2/4/20 3:56 PM, Moayad Almalat wrote:
> From: Moayad <m.almalat at proxmox.com>
> 
> Signed-off-by: Moayad <m.almalat at proxmox.com>
> ---
>  PVE/VZDump.pm | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
> index 3caa7ab8..0f04d4db 100644
> --- a/PVE/VZDump.pm
> +++ b/PVE/VZDump.pm
> @@ -405,6 +405,10 @@ sub new {
>  	}
>      }
>  
> +    if (defined($opts->{pigz})) {
> +	$opts->{pigz} = PVE::JSONSchema::parse_property_string(PVE::VZDump::Common::get_pigzdesc(), $opts->{pigz});

see the other mail regarding confdesc/pigzfmt - in general this line
would be to long either way.

I'd maybe also guard the parsing with a "ref" check, i.e., check if
our caller already parsed that property, for example something like:

if (defined($opts->{pigz}) && !ref($opts->{pigz})) {
    ...

> +    }
> +
>      $opts->{dumpdir} =~ s|/+$|| if ($opts->{dumpdir});
>      $opts->{tmpdir} =~ s|/+$|| if ($opts->{tmpdir});
>  
> @@ -582,8 +586,8 @@ sub compressor_info {
>      } elsif ($opt_compress eq '1' || $opt_compress eq 'lzo') {
>  	return ('lzop', 'lzo');
>      } elsif ($opt_compress eq 'gzip') {
> -	if ($opts->{pigz} > 0) {
> -	    my $pigz_threads = $opts->{pigz};
> +	if (defined($opts->{pigz}) && $opts->{pigz}->{threads} > 0) {

we do not really care about auto-vivification here so you could omit
the defined check here. We do not have any special behavior for
$opt->{pigz} existing but having a undef or {} value after all.

> +	    my $pigz_threads = $opts->{pigz}->{threads};
>  	    if ($pigz_threads == 1) {
>  		my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
>  		$pigz_threads = int(($cpuinfo->{cpus} + 1)/2);
> 

 




More information about the pve-devel mailing list