[pve-devel] [PATCH] fix bug 713: implement activate snapshot
Wolfgang Link
w.link at proxmox.com
Fri Sep 18 11:57:06 CEST 2015
before we can backup an container in snapshot mode on RBD we must activate it.
---
src/PVE/VZDump/LXC.pm | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index 2d4b85a..93f1399 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -176,10 +176,12 @@ sub unlock_vm {
sub snapshot {
my ($self, $task, $vmid) = @_;
+ my $snapname = 'vzdump';
+
$self->loginfo("create storage snapshot snapshot");
# todo: freeze/unfreeze if we have more than one volid
- PVE::LXC::snapshot_create($vmid, 'vzdump', "vzdump backup snapshot");
+ PVE::LXC::snapshot_create($vmid, $snapname, "vzdump backup snapshot");
$task->{cleanup}->{remove_snapshot} = 1;
# reload config
@@ -190,6 +192,13 @@ sub snapshot {
my $disks = $task->{disks};
my $volid_list = [map { $_->{volume} } @$disks];
+ my $vollist = PVE::LXC::get_vm_volumes($conf);
+ my $storecfg = PVE::Storage::config();
+
+ PVE::Storage::activate_volumes($storecfg, $vollist, $snapname);
+
+ $task->{cleanup}->{deactivate_snapshot} = $snapname;
+
my $rootdir = $default_mount_point;
my $storage_cfg = $self->{storecfg};
@@ -316,7 +325,7 @@ sub cleanup {
my ($self, $task, $vmid) = @_;
my $conf = PVE::LXC::load_config($vmid);
-
+
if ($task->{mode} ne 'suspend') {
my $rootdir = $default_mount_point;
my $disks = $task->{disks};
@@ -325,6 +334,14 @@ sub cleanup {
}
}
+ if ($task->{cleanup}->{deactivate_snapshot}) {
+ my $conf = PVE::LXC::load_config($vmid);
+ my $vollist = PVE::LXC::get_vm_volumes($conf);
+ my $storecfg = PVE::Storage::config();
+
+ PVE::Storage::deactivate_volumes($storecfg, $vollist, $task->{cleanup}->{deactivate_snapshot});
+ }
+
if ($task->{cleanup}->{remove_snapshot}) {
$self->loginfo("remove vzdump snapshot");
PVE::LXC::snapshot_delete($vmid, 'vzdump', 0);
--
2.1.4
More information about the pve-devel
mailing list