[pve-devel] [PATCH qemu-server 1/2] Make snapshot_save_vmstate proper sub

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Feb 25 15:51:01 CET 2016


---
 PVE/QemuServer.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6a41d2b..32b9343 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5929,7 +5929,7 @@ my $alloc_vmstate_volid = sub {
     return $volid;
 };
 
-my $snapshot_save_vmstate = sub {
+sub snapshot_save_vmstate {
     my ($vmid, $conf, $snapname, $storecfg) = @_;
 
     my $snap = $conf->{snapshots}->{$snapname};
@@ -5938,7 +5938,7 @@ my $snapshot_save_vmstate = sub {
     # always overwrite machine if we save vmstate. This makes sure we
     # can restore it later using correct machine type
     $snap->{machine} = get_current_qemu_machine($vmid);
-};
+}
 
 sub snapshot_prepare {
     my ($vmid, $snapname, $save_vmstate, $comment) = @_;
@@ -5961,11 +5961,12 @@ sub snapshot_prepare {
 
 	my $storecfg = PVE::Storage::config();
 	die "snapshot feature is not available\n" if !has_feature('snapshot', $conf, $storecfg);
+	my $running = check_running($vmid);
 
 	$snap = $conf->{snapshots}->{$snapname} = {};
 
-	if ($save_vmstate && check_running($vmid)) {
-	    &$snapshot_save_vmstate($vmid, $conf, $snapname, $storecfg);
+	if ($save_vmstate && $running) {
+	    snapshot_save_vmstate($vmid, $conf, $snapname, $storecfg);
 	}
 
 	&$snapshot_copy_config($conf, $snap);
-- 
2.1.4





More information about the pve-devel mailing list