[pve-devel] [PATCH 09/44] rbd : free_image : unprotect snapshot is base
Alexandre Derumier
aderumier at odiso.com
Tue Feb 5 12:55:36 CET 2013
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Storage/RBDPlugin.pm | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 46c66e8..8bcdb59 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -312,10 +312,22 @@ sub alloc_image {
sub free_image {
my ($class, $storeid, $scfg, $volname, $isBase) = @_;
- my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge', $volname);
+ my ($vtype, $name, $vmid, undef, undef, undef) =
+ $class->parse_volname($volname);
+
+ if ($isBase) {
+ my $snap = '__base__';
+ my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $name, $snap);
+ if ($protected){
+ my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'unprotect', $name, '--snap', $snap);
+ run_command($cmd, errmsg => "rbd unprotect $name snap $snap' error", errfunc => sub {});
+ }
+ }
+
+ my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge', $name);
run_command($cmd, errmsg => "rbd snap purge $volname' error", outfunc => sub {}, errfunc => sub {});
- $cmd = &$rbd_cmd($scfg, $storeid, 'rm', $volname);
+ $cmd = &$rbd_cmd($scfg, $storeid, 'rm', $name);
run_command($cmd, errmsg => "rbd rm $volname' error", outfunc => sub {}, errfunc => sub {});
return undef;
--
1.7.10.4
More information about the pve-devel
mailing list