From 3a8deb551f2c7648865437961b3593d11bf0591b Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Mon, 14 Nov 2016 13:23:02 +0100 Subject: [PATCH] vmstate snapshot : activate|deactivate volume This fix vmstate snasphot on krbd volume Signed-off-by: Alexandre Derumier --- PVE/QemuConfig.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm index 3ce95ac..692bba8 100644 --- a/PVE/QemuConfig.pm +++ b/PVE/QemuConfig.pm @@ -137,10 +137,13 @@ sub __snapshot_create_vol_snapshots_hook { my ($class, $vmid, $snap, $running, $hook) = @_; if ($running) { + my $storecfg = PVE::Storage::config(); + if ($hook eq "before") { if ($snap->{vmstate}) { - my $storecfg = PVE::Storage::config(); my $path = PVE::Storage::path($storecfg, $snap->{vmstate}); + PVE::Storage::activate_volumes($storecfg, [$snap->{vmstate}]); + PVE::QemuServer::vm_mon_cmd($vmid, "savevm-start", statefile => $path); for(;;) { my $stat = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "query-savevm"); @@ -159,7 +162,10 @@ sub __snapshot_create_vol_snapshots_hook { PVE::QemuServer::vm_mon_cmd($vmid, "savevm-start"); } } elsif ($hook eq "after") { - eval { PVE::QemuServer::vm_mon_cmd($vmid, "savevm-end") }; + eval { + PVE::QemuServer::vm_mon_cmd($vmid, "savevm-end"); + PVE::Storage::deactivate_volumes($storecfg, [$snap->{vmstate}]) if $snap->{vmstate}; + }; warn $@ if $@; } elsif ($hook eq "after-freeze") { # savevm-end is async, we need to wait -- 2.39.2