[pve-devel] [PATCH 01/20] storage: add volume_protect && volume_unprotect

Alexandre Derumier aderumier at odiso.com
Mon Dec 3 14:32:26 CET 2012


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Storage.pm |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index b13df21..d654d6f 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -183,6 +183,36 @@ sub volume_snapshot_delete {
     }
 }
 
+sub volume_protect {
+    my ($cfg, $volid, $snap) = @_;
+
+    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_protect($scfg, $storeid, $volname, $snap);
+    } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
+        die "protect a device is not possible";
+    } else {
+        die "can't protect";
+    }
+}
+
+sub volume_unprotect {
+    my ($cfg, $volid, $snap) = @_;
+
+    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_unprotect($scfg, $storeid, $volname, $snap);
+    } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
+        die "unprotect a device is not possible";
+    } else {
+        die "can't unprotect";
+    }
+}
+
 sub get_image_dir {
     my ($cfg, $storeid, $vmid) = @_;
 
-- 
1.7.10.4




More information about the pve-devel mailing list