[pve-devel] [PATCH] volume_snapshot : add testfeature option param
Alexandre Derumier
aderumier at odiso.com
Fri Sep 28 16:22:29 CEST 2012
return 1 for storage which support snapshot before doing the snapshot
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Storage.pm | 4 ++--
PVE/Storage/NexentaPlugin.pm | 4 +++-
PVE/Storage/Plugin.pm | 6 +++---
PVE/Storage/RBDPlugin.pm | 4 ++--
PVE/Storage/SheepdogPlugin.pm | 6 +++---
5 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 271b3f9..6771e73 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -139,13 +139,13 @@ sub volume_resize {
}
sub volume_snapshot {
- my ($cfg, $volid, $snap, $running) = @_;
+ my ($cfg, $volid, $snap, $running, $testfeature) = @_;
my ($storeid, $volname) = parse_volume_id($volid, 1);
if ($storeid) {
my $scfg = storage_config($cfg, $storeid);
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
- return $plugin->volume_snapshot($scfg, $storeid, $volname, $snap, $running);
+ return $plugin->volume_snapshot($scfg, $storeid, $volname, $snap, $running, $testfeature);
} elsif ($volid =~ m|^(/.+)$| && -e $volid) {
die "snapshot device is not possible";
} else {
diff --git a/PVE/Storage/NexentaPlugin.pm b/PVE/Storage/NexentaPlugin.pm
index a5b6fe2..7b78de8 100644
--- a/PVE/Storage/NexentaPlugin.pm
+++ b/PVE/Storage/NexentaPlugin.pm
@@ -347,7 +347,9 @@ sub volume_resize {
}
sub volume_snapshot {
- my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
+ my ($class, $scfg, $storeid, $volname, $snap, $running, $testfeature) = @_;
+
+ return 1 if $testfeature;
nexenta_request($scfg, 'create_snapshot', 'zvol', "$scfg->{pool}/$volname", $snap, '');
}
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 41427c5..b48ee70 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -510,11 +510,11 @@ sub volume_resize {
}
sub volume_snapshot {
- my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
+ my ($class, $scfg, $storeid, $volname, $snap, $running, $testfeature) = @_;
- die "can't snapshot this image format" if $volname !~ m/\.(qcow2|qed)$/;
+ die "can't snapshot this image format" if $volname !~ m/\.(qcow2)$/;
- return 1 if $running;
+ return 1 if $running || $testfeature;
my $path = $class->path($scfg, $volname);
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 6d1d741..daba905 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -279,9 +279,9 @@ sub volume_resize {
}
sub volume_snapshot {
- my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
+ my ($class, $scfg, $storeid, $volname, $snap, $running, $testfeature) = @_;
- return 1 if $running;
+ return 1 if $running || $testfeature;
my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'create', '--snap', $snap, $volname);
run_command($cmd, errmsg => "rbd snapshot $volname' error", errfunc => sub {});
diff --git a/PVE/Storage/SheepdogPlugin.pm b/PVE/Storage/SheepdogPlugin.pm
index 346a2f2..ee8a057 100644
--- a/PVE/Storage/SheepdogPlugin.pm
+++ b/PVE/Storage/SheepdogPlugin.pm
@@ -243,9 +243,9 @@ sub volume_resize {
}
sub volume_snapshot {
- my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
-
- return 1 if $running;
+ my ($class, $scfg, $storeid, $volname, $snap, $running, $testfeature) = @_;
+
+ return 1 if $running || $testfeature;
my $cmd = &$collie_cmd($scfg, 'vdi', 'snapshot', '-s', $snap, $volname);
run_command($cmd, errmsg => "sheepdog snapshot $volname' error");
--
1.7.10
More information about the pve-devel
mailing list