From e67069eb58a2766ec31bb3932a203c71f51d9654 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 27 Aug 2015 12:03:46 +0200 Subject: [PATCH] path: corretly implement path to snapshots --- PVE/Storage/DRBDPlugin.pm | 4 +++- PVE/Storage/GlusterfsPlugin.pm | 10 ++++++++-- PVE/Storage/ISCSIDirectPlugin.pm | 5 ++++- PVE/Storage/ISCSIPlugin.pm | 4 +++- PVE/Storage/LVMPlugin.pm | 4 +++- PVE/Storage/Plugin.pm | 14 ++++++++++---- PVE/Storage/ZFSPlugin.pm | 5 ++++- PVE/Storage/ZFSPoolPlugin.pm | 3 ++- 8 files changed, 37 insertions(+), 12 deletions(-) diff --git a/PVE/Storage/DRBDPlugin.pm b/PVE/Storage/DRBDPlugin.pm index 0dbe06d..b209ac8 100644 --- a/PVE/Storage/DRBDPlugin.pm +++ b/PVE/Storage/DRBDPlugin.pm @@ -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); diff --git a/PVE/Storage/GlusterfsPlugin.pm b/PVE/Storage/GlusterfsPlugin.pm index 890efcf..7a8c82f 100644 --- a/PVE/Storage/GlusterfsPlugin.pm +++ b/PVE/Storage/GlusterfsPlugin.pm @@ -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') { diff --git a/PVE/Storage/ISCSIDirectPlugin.pm b/PVE/Storage/ISCSIDirectPlugin.pm index 66a87ad..d20fbe2 100644 --- a/PVE/Storage/ISCSIDirectPlugin.pm +++ b/PVE/Storage/ISCSIDirectPlugin.pm @@ -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); diff --git a/PVE/Storage/ISCSIPlugin.pm b/PVE/Storage/ISCSIPlugin.pm index e456c0d..7614bf0 100644 --- a/PVE/Storage/ISCSIPlugin.pm +++ b/PVE/Storage/ISCSIPlugin.pm @@ -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); diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm index 94d3e6d..c02fe59 100644 --- a/PVE/Storage/LVMPlugin.pm +++ b/PVE/Storage/LVMPlugin.pm @@ -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); diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 8341fd3..7325535 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -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 { diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm index e7acfb8..3878342 100644 --- a/PVE/Storage/ZFSPlugin.pm +++ b/PVE/Storage/ZFSPlugin.pm @@ -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); diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index 50045e9..75704b0 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -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!"; }