[pve-devel] [PATCH 3/7] fix bug #691: implement zfs vzdump backup
Wolfgang Link
w.link at proxmox.com
Mon Aug 24 10:48:32 CEST 2015
---
src/PVE/VZDump/LXC.pm | 48 ++++++++++++++++++++++++++++++++----------------
1 file changed, 32 insertions(+), 16 deletions(-)
diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index 32a85db..cd43f98 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -105,6 +105,13 @@ my $loop_mount_image = sub {
}
};
+sub snapshot {
+ my ($self, $task, $vmid) = @_;
+
+ #do notthing every necessary thing done in prepade!
+}
+
+
sub prepare {
my ($self, $task, $vmid, $mode) = @_;
@@ -130,25 +137,34 @@ sub prepare {
die "mode failure - storage does not support snapshots\n"
if !PVE::Storage::volume_has_feature($self->{storecfg}, 'snapshot', $volid);
-
+
my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
my $scfg = PVE::Storage::storage_config($self->{storecfg}, $sid);
# we only handle well known types for now, because the storage
# library dos not handle mount/unmount of snapshots
+ die "mode failure - storage does not support snapshot mount\n"
+ if !($scfg->{type} eq 'zfspool');
- if ($scfg->{type} ne 'zfs') {
- $diskinfo->{mountpoint} = "/mnt/vzsnap0";
- } else {
- die "mode failure - storage does not support snapshot mount\n"
- }
-
- PVE::Storage::volume_snapshot($self->{storecfg}, $volid, '__vzdump__');
+ my $snap = '__vzdump__';
+ PVE::Storage::volume_snapshot($self->{storecfg}, $volid, $snap);
$task->{cleanup}->{snap_volid} = $volid;
-
- die "implement me";
-
+
+ if ($scfg->{type} eq 'zfspool') {
+ sleep(2);
+ my $mountpoint = "/mnt/vzsnap0";
+ my $path = PVE::Storage::path(PVE::Storage::config(), $volid,);
+
+ $path = substr($path, 1);
+ $path .= "@".$snap;
+
+ &$mount_dev($path, $mountpoint, 'zfs');
+
+ $task->{cleanup}->{snapshot_mount} = 1;
+ $diskinfo->{dir} = $diskinfo->{mountpoint} = $mountpoint;
+ }
+
} else {
if ($mode eq 'stop') {
@@ -168,12 +184,12 @@ sub prepare {
} else {
die "unknown mode '$mode'\n"; # should not happen
}
+ }
- if ($mode eq 'suspend') {
- $task->{snapdir} = $task->{tmpdir};
- } else {
- $task->{snapdir} = $diskinfo->{dir};
- }
+ if ($mode eq 'suspend') {
+ $task->{snapdir} = $task->{tmpdir};
+ } else {
+ $task->{snapdir} = $diskinfo->{dir};
}
}
--
2.1.4
More information about the pve-devel
mailing list