This fix vmstate snasphot on krbd volume

Signed-off-by: Alexandre Derumier <aderum...@odiso.com>
---
 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.1.4

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to