[pve-devel] [PATCH container 2/9] adapt config GET call for taking pending changes

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Sep 11 14:08:18 CEST 2019


On 11.09.19 09:39, Fabian Grünbichler wrote:
> On September 5, 2019 4:11 pm, Oguz Bektas wrote:
>> +	# take pending changes in
>> +	if (!$param->{current}) {
>> +	    foreach my $opt (keys %{$conf->{pending}}) {
>> +		next if $opt eq 'delete';
>> +		my $value = $conf->{pending}->{$opt};
>> +		next if ref($value); # just to be sure
>> +		$conf->{$opt} = $value;
>> +	    }
>> +	    my $pending_delete_hash = PVE::LXC::Config->split_flagged_list($conf->{pending}->{delete});
>> +	    foreach my $opt (keys %$pending_delete_hash) {
>> +		delete $conf->{$opt} if $conf->{$opt};
>> +	    }
>> +	}
>> +
>> +
>>  	delete $conf->{snapshots};
>> +	delete $conf->{pending};
> 
> the whole thing is now identical (modulo comments and line ordering) to 
> the same Qemu API path, except that Qemu also masks the 'cipassword' 
> option if it is set.
> 
> we could instead move the whole 'delete snapshots, conditionally apply 
> or delete pending changes' into a new AbstractConfig method 
> (e.g., load_current_config($apply_pending)), or add two parameters to 
> load_config to get this reduced config instead of the full one.

Maybe move it there and have qemu overwrite it alá 

sub load_current_config {
	my $conf = $class->SUPER::load_current_config(@_);

	if ($conf->{cipassword}) {
	    $conf->{cipassword} = '**********';
	}

	return $conf;
}

to ensure the cipassword never get's out?
Could be "fixed up" by the caller too, depends on re-use potential.





More information about the pve-devel mailing list