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

Oguz Bektas o.bektas at proxmox.com
Tue Nov 26 18:59:56 CET 2019


replace redundant write/load config calls with a single write_config at
the end to avoid unnecessary i/o

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 {
-- 
2.20.1




More information about the pve-devel mailing list