]> git.proxmox.com Git - pve-storage.git/commitdiff
path: corretly implement path to snapshots
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 27 Aug 2015 10:03:46 +0000 (12:03 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 27 Aug 2015 10:03:46 +0000 (12:03 +0200)
PVE/Storage/DRBDPlugin.pm
PVE/Storage/GlusterfsPlugin.pm
PVE/Storage/ISCSIDirectPlugin.pm
PVE/Storage/ISCSIPlugin.pm
PVE/Storage/LVMPlugin.pm
PVE/Storage/Plugin.pm
PVE/Storage/ZFSPlugin.pm
PVE/Storage/ZFSPoolPlugin.pm

index 0dbe06d79007f39afb755283ac12c3d116c51b4c..b209ac814afcd04b37545e431c2f4c8d56bf334b 100644 (file)
@@ -140,7 +140,9 @@ sub parse_volname {
 }
 
 sub filesystem_path {
-    my ($class, $scfg, $volname) = @_;
+    my ($class, $scfg, $volname, $snapname) = @_;
+
+    die "drbd snapshot is not implemented\n" if defined($snapname);
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
index 890efcf832c7b3e37f5208bbe19d89e3e55a9c02..7a8c82fbee81a9f9b2153bb18847038855675b2d 100644 (file)
@@ -191,9 +191,15 @@ my $find_free_diskname = sub {
 };
 
 sub path {
-    my ($class, $scfg, $volname, $storeid) = @_;
+    my ($class, $scfg, $volname, $storeid, $snapname) = @_;
 
-    my ($vtype, $name, $vmid) = $class->parse_volname($volname);
+    my ($vtype, $name, $vmid, undef, undef, $isBase, $format) =
+       $class->parse_volname($volname);
+
+    # Note: qcow2/qed has internal snapshot, so path is always
+    # the same (with or without snapshot => same file).
+    die "can't snapshot this image format\n" 
+       if defined($snapname) && $format !~ m/^(qcow2|qed)$/;
 
     my $path = undef;
     if ($vtype eq 'images') {
index 66a87adbead52b702427d20d2f934072bf407dad..d20fbe2fa443f85b687ec55d9be8410897eb6dae 100644 (file)
@@ -85,7 +85,10 @@ sub parse_volname {
 }
 
 sub path {
-    my ($class, $scfg, $volname) = @_;
+    my ($class, $scfg, $volname, $storeid, $snapname) = @_;
+
+    die "volume snapshot is not possible on iscsi device"
+       if defined($snapname);
 
     my ($vtype, $lun, $vmid) = $class->parse_volname($volname);
 
index e456c0d1a3afbed77b8cd918120cd09c37ef5e32..7614bf093449a6daa8d1a321e99cdfc1f52826bb 100644 (file)
@@ -278,7 +278,9 @@ sub parse_volname {
 }
 
 sub filesystem_path {
-    my ($class, $scfg, $volname) = @_;
+    my ($class, $scfg, $volname, $snapname) = @_;
+
+    die "snapshot is not possible on iscsi storage\n" if defined($snapname);
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
     
index 94d3e6d542a7245ff9eb7626980776e4bb1a28cf..c02fe593eb337d2768d49d09d379f38c91068b7e 100644 (file)
@@ -228,7 +228,9 @@ sub parse_volname {
 }
 
 sub filesystem_path {
-    my ($class, $scfg, $volname) = @_;
+    my ($class, $scfg, $volname, $snapname) = @_;
+
+    die "lvm snapshot is not implemented"if defined($snapname);
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
index 8341fd3bab52478a8d999315d70dab5c924a3a4b..7325535afd1075efadd4a097894a73aeba24eaba 100644 (file)
@@ -403,9 +403,15 @@ sub get_subdir {
 }
 
 sub filesystem_path {
-    my ($class, $scfg, $volname, $storeid) = @_;
+    my ($class, $scfg, $volname, $snapname) = @_;
 
-    my ($vtype, $name, $vmid) = $class->parse_volname($volname);
+    my ($vtype, $name, $vmid, undef, undef, $isBase, $format) =
+       $class->parse_volname($volname);
+
+    # Note: qcow2/qed has internal snapshot, so path is always
+    # the same (with or without snapshot => same file).
+    die "can't snapshot this image format\n"
+       if defined($snapname) && $format !~ m/^(qcow2|qed)$/;
 
     my $dir = $class->get_subdir($scfg, $vtype);
 
@@ -417,9 +423,9 @@ sub filesystem_path {
 }
 
 sub path {
-    my ($class, $scfg, $volname, $storeid) = @_;
+    my ($class, $scfg, $volname, $storeid, $snapname) = @_;
 
-    return $class->filesystem_path($scfg, $volname, $storeid);
+    return $class->filesystem_path($scfg, $volname, $snapname);
 }
 
 sub create_base {
index e7acfb881d7614f0c8e20597ad11276b8a0230d9..387834211dd6177e17b09d7dde103a98c209cc10 100644 (file)
@@ -208,7 +208,10 @@ sub options {
 # Storage implementation
 
 sub path {
-    my ($class, $scfg, $volname) = @_;
+    my ($class, $scfg, $volname, $storeid, $snapname) = @_;
+
+    die "direct access to snapshots not implemented"
+       if defined($snapname);
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
index 50045e98411c61d733cc1776ad44ec315317ce83..75704b048fa67cd86887b16c5fa7dbf25d2afc3c 100644 (file)
@@ -141,7 +141,7 @@ sub parse_volname {
 # virtual zfs methods (subclass can overwrite them)
 
 sub path {
-    my ($class, $scfg, $volname) = @_;
+    my ($class, $scfg, $volname, $storeid, $snapname) = @_;
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
@@ -154,6 +154,7 @@ sub path {
        } else {
            $path = "/dev/zvol/$scfg->{pool}/$volname";
        }
+       $path .= "\@$snapname" if defined($snapname);
     } else {
        die "$vtype is not allowed in ZFSPool!";
     }