[pve-devel] [PATCH qemu-server 2/3] apply_pending: remove redundant write/load config calls

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Dec 12 14:51:11 CET 2019


On 11/26/19 6:59 PM, Oguz Bektas wrote:
> replace redundant write/load config calls with a single write_config at
> the end to avoid unnecessary i/o

cannot be done at this point, there's code which can die, and thus
get the config in an out-of-sync state, where something was done, but
not recorded in the config, as another change died.

order this after 3/3 (plus 3/3 needs another fix, see reply there)

> 
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
>  PVE/QemuServer.pm | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 9749917..7d2959a 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -4979,27 +4979,19 @@ sub vmconfig_apply_pending {
>      foreach my $opt (sort keys %$pending_delete_hash) {
>  	die "internal error" if $opt =~ m/^unused/;
>  	my $force = $pending_delete_hash->{$opt}->{force};
> -	$conf = PVE::QemuConfig->load_config($vmid); # update/reload
>  	if (!defined($conf->{$opt})) {
>  	    PVE::QemuConfig->remove_from_pending_delete($conf, $opt);
> -	    PVE::QemuConfig->write_config($vmid, $conf);
>  	} elsif (is_valid_drivename($opt)) {
>  	    vmconfig_delete_or_detach_drive($vmid, $storecfg, $conf, $opt, $force);
>  	    PVE::QemuConfig->remove_from_pending_delete($conf, $opt);
>  	    delete $conf->{$opt};
> -	    PVE::QemuConfig->write_config($vmid, $conf);
>  	} else {
>  	    PVE::QemuConfig->remove_from_pending_delete($conf, $opt);
>  	    delete $conf->{$opt};
> -	    PVE::QemuConfig->write_config($vmid, $conf);
>  	}
>      }
>  
> -    $conf = PVE::QemuConfig->load_config($vmid); # update/reload
> -
>      foreach my $opt (keys %{$conf->{pending}}) { # add/change
> -	$conf = PVE::QemuConfig->load_config($vmid); # update/reload
> -
>  	if (defined($conf->{$opt}) && ($conf->{$opt} eq $conf->{pending}->{$opt})) {
>  	    # skip if nothing changed
>  	} elsif (is_valid_drivename($opt)) {
> @@ -5011,8 +5003,9 @@ sub vmconfig_apply_pending {
>  	}
>  
>  	delete $conf->{pending}->{$opt};
> -	PVE::QemuConfig->write_config($vmid, $conf);
>      }
> +
> +    PVE::QemuConfig->write_config($vmid, $conf);
>  }
>  
>  my $safe_num_ne = sub {
> 





More information about the pve-devel mailing list