]> git.proxmox.com Git - qemu-server.git/commitdiff
vmstate snapshot : activate|deactivate volume
authorAlexandre Derumier <aderumier@odiso.com>
Mon, 14 Nov 2016 12:23:02 +0000 (13:23 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 17 Nov 2016 08:46:54 +0000 (09:46 +0100)
This fix vmstate snasphot on krbd volume

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/QemuConfig.pm

index 3ce95ac86b5cc4de7d5e17cff7ad829326575aa3..692bba88722b7cad5d3a11d5a87f38ab3b44ed5e 100644 (file)
@@ -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