[pve-devel] [PATCH qemu-server] Refactor snapshot_create to match LXC.pm
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Feb 24 12:33:31 CET 2016
---
further preparation to merge the common code base of LXC and Qemu
PVE/QemuServer.pm | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index c199437..3217af5 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6162,6 +6162,17 @@ sub qga_check_running {
return 1;
}
+sub check_freeze_needed {
+ my ($vmid, $config, $save_vmstate) = @_;
+
+ my $running = check_running($vmid);
+ if ($save_vmstate) {
+ return ($running, $running && $config->{agent} && qga_check_running($vmid));
+ } else {
+ return ($running, 0);
+ }
+}
+
sub snapshot_create {
my ($vmid, $snapname, $save_vmstate, $comment) = @_;
@@ -6171,19 +6182,16 @@ sub snapshot_create {
my $config = load_config($vmid);
- my $running = check_running($vmid);
-
- my $freezefs = $running && $config->{agent} && qga_check_running($vmid);
- $freezefs = 0 if $snap->{vmstate}; # not needed if we save RAM
+ my ($running, $freezefs) = check_freeze_needed($vmid, $config, $snap->{vmstate});
my $drivehash = {};
- if ($freezefs) {
- eval { vm_mon_cmd($vmid, "guest-fsfreeze-freeze"); };
- warn "guest-fsfreeze-freeze problems - $@" if $@;
- }
-
eval {
+ if ($freezefs) {
+ eval { vm_mon_cmd($vmid, "guest-fsfreeze-freeze"); };
+ warn "guest-fsfreeze-freeze problems - $@" if $@;
+ }
+
# create internal snapshots of all drives
my $storecfg = PVE::Storage::config();
@@ -6236,7 +6244,7 @@ sub snapshot_create {
if ($err) {
warn "snapshot create failed: starting cleanup\n";
- eval { snapshot_delete($vmid, $snapname, 0, $drivehash); };
+ eval { snapshot_delete($vmid, $snapname, 1, $drivehash); };
warn $@ if $@;
die $err;
}
--
2.1.4
More information about the pve-devel
mailing list