]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/RBDPlugin.pm
bump version to 4.0-51
[pve-storage.git] / PVE / Storage / RBDPlugin.pm
index 4fe634511c37b816842dc4a5a103961b0aa22487..967ee0448f49e792cb2bfd555b9133e2da606843 100644 (file)
@@ -489,7 +489,7 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     return 1 if !$scfg->{krbd};
 
@@ -497,8 +497,10 @@ sub activate_volume {
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
 
     my $path = "/dev/rbd/$pool/$name";
+    $path .= '@'.$snapname if $snapname;
     return if -b $path;
 
+    $name .= '@'.$snapname if $snapname;
     my $cmd = &$rbd_cmd($scfg, $storeid, 'map', $name);
     run_rbd_command($cmd, errmsg => "can't mount rbd volume $name");
 
@@ -506,7 +508,7 @@ sub activate_volume {
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
     return 1 if !$scfg->{krbd};
 
@@ -514,10 +516,11 @@ sub deactivate_volume {
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
 
     my $path = "/dev/rbd/$pool/$name";
+    $path .= '@'.$snapname if $snapname;
     return if ! -b $path;
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'unmap', $path);
-    run_rbd_command($cmd, errmsg => "can't unmount rbd volume $name");
+    run_rbd_command($cmd, errmsg => "can't unmap rbd volume $name");
 
     return 1;
 }
@@ -566,6 +569,8 @@ sub volume_snapshot_delete {
 
     return 1 if $running;
 
+    $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
+
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
     my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $name, $snap);
@@ -589,6 +594,7 @@ sub volume_has_feature {
        clone => { base => 1, snap => 1},
        template => { current => 1},
        copy => { base => 1, current => 1, snap => 1},
+       sparseinit => { base => 1, current => 1},
     };
 
     my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =