]> git.proxmox.com Git - pve-storage.git/commitdiff
rbd : free_image : unprotect snapshot is base
authorAlexandre Derumier <aderumier@odiso.com>
Tue, 5 Feb 2013 11:55:36 +0000 (12:55 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 14 Feb 2013 08:40:26 +0000 (09:40 +0100)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/Storage/RBDPlugin.pm

index eee2c72e025fa3dc246c56eda354b1bc07328183..4ac2884844054a685279ce82bd6659d668ad6501 100644 (file)
@@ -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;