---
 src/PVE/VZDump/LXC.pm | 43 ++++++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index a6a0639..cb228ca 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -66,6 +66,12 @@ sub vm_status {
     return wantarray ? ($running, $running ? 'running' : 'stopped') : 
$running; 
 }
 
+sub snapshot {
+    my ($self, $task, $vmid) = @_;
+
+    #do nothing. every thing done in prepare!
+}
+
 my $mount_dev = sub {
     my ($dev, $mountpoint, $fs) = @_;
 
@@ -143,18 +149,25 @@ sub prepare {
        # we only handle well known types for now, because the storage
        # library dos not handle mount/unmount of snapshots
 
-       if ($scfg->{type} ne 'zfs') {
-           $diskinfo->{mountpoint} = $mountpoint;
-           $diskinfo->{no_unmount} = 1;
-       } else {
-           die "mode failure - storage does not support snapshot mount\n"
-       }
-       
+       die "mode failure - storage does not support snapshot mount\n"
+           if !($scfg->{type} eq 'zfspool');
+
        PVE::Storage::volume_snapshot($self->{storecfg}, $volid, '__vzdump__');
        $task->{cleanup}->{snap_volid} = $volid;
-       
-       die "implement me";
-       
+
+       if ($scfg->{type} eq 'zfspool') {
+           sleep(2);
+           my $path = PVE::Storage::path(PVE::Storage::config(), $volid,);
+
+           $path = substr($path, 1);
+           $path .= '@__vzdump__';
+
+           &$mount_dev($path, $mountpoint, 'zfs');
+
+           $task->{cleanup}->{snapshot_mount} = $mountpoint;
+           $diskinfo->{dir} = $diskinfo->{mountpoint} = $mountpoint;
+       }
+
     } else {
 
        if ($mode eq 'stop') {
@@ -174,12 +187,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


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

Reply via email to