[pve-devel] [PATCH RFC qemu-server] Don't apply snapshot config in snapshot_commit

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Feb 25 16:26:58 CET 2016


We hold a lock from snapshot_prepare until snapshot_commit,
so there is no need to copy back the snapshot config to the
actual config. This allows to drop a workaround for not
copying the 'machine' type config option.
---
The current VM config is copied to the snapshot config in
snapshot_prepare(). Afterwards, the VM config itself is
only touched to remove the lock and update the parent
(both in snapshot_commit()) and the snapshot config only
gets additional snapshot-related config options.

Since those snapshot-related config options would get
dropped when copying back to the VM config, copying back
with snapshot_apply_config does not make much sense IMHO.

Dropping the workaround for the machine option allows
us to completely merge snapshot_commit with LXC's version,
at least after the call to snapshot_apply_config is dropped
there as well.

RFC in case I missed some corner case where relevant changes
to the snapshot configuration - but not the VM configuration -
do happen and need to be copied/applied back to the VM config.

 PVE/QemuServer.pm | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6a41d2b..d9f2e23 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5992,8 +5992,6 @@ sub snapshot_commit {
 	die "missing snapshot lock\n"
 	    if !($conf->{lock} && $conf->{lock} eq 'snapshot');
 
-	my $has_machine_config = defined($conf->{machine});
-
 	my $snap = $conf->{snapshots}->{$snapname};
 
 	die "snapshot '$snapname' does not exist\n" if !defined($snap);
@@ -6004,13 +6002,9 @@ sub snapshot_commit {
 	delete $snap->{snapstate};
 	delete $conf->{lock};
 
-	my $newconf = &$snapshot_apply_config($conf, $snap);
-
-	delete $newconf->{machine} if !$has_machine_config;
+	$conf->{parent} = $snapname;
 
-	$newconf->{parent} = $snapname;
-
-	write_config($vmid, $newconf);
+	write_config($vmid, $conf);
     };
 
     lock_config($vmid, $updatefn);
-- 
2.1.4





More information about the pve-devel mailing list