]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/RBDPlugin.pm
pbs: allow setting up a master key
[pve-storage.git] / PVE / Storage / RBDPlugin.pm
index 41d89b5bc32197594bc064d06e3906408d4c24a2..a8d1243c50e1a950fbbe6aa88ac4953d6005b34e 100644 (file)
@@ -2,14 +2,17 @@ package PVE::Storage::RBDPlugin;
 
 use strict;
 use warnings;
+
 use IO::File;
+use JSON;
 use Net::IP;
-use PVE::Tools qw(run_command trim);
-use PVE::Storage::Plugin;
+
+use PVE::CephConfig;
 use PVE::JSONSchema qw(get_standard_option);
+use PVE::ProcFSTools;
 use PVE::RADOS;
-use PVE::Storage::CephTools;
-use JSON;
+use PVE::Storage::Plugin;
+use PVE::Tools qw(run_command trim);
 
 use base qw(PVE::Storage::Plugin);
 
@@ -19,22 +22,29 @@ my $get_parent_image_name = sub {
     return $parent->{image} . "@" . $parent->{snapshot};
 };
 
-my $add_pool_to_disk = sub {
-    my ($scfg, $disk) = @_;
-
-    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
-
-    return "$pool/$disk";
+my sub get_rbd_path {
+    my ($scfg, $volume) = @_;
+    my $path = $scfg->{pool} ? $scfg->{pool} : 'rbd';
+    $path .= "/$scfg->{namespace}" if defined($scfg->{namespace});
+    $path .= "/$volume" if defined($volume);
+    return $path;
 };
 
 my $build_cmd = sub {
     my ($binary, $scfg, $storeid, $op, @options) = @_;
 
-    my $cmd_option = PVE::Storage::CephTools::ceph_connect_option($scfg, $storeid);
+    my $cmd_option = PVE::CephConfig::ceph_connect_option($scfg, $storeid);
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
 
     my $cmd = [$binary, '-p', $pool];
 
+    if (defined(my $namespace = $scfg->{namespace})) {
+       # some subcommands will fail if the --namespace parameter is present
+       my $no_namespace_parameter = {
+           unmap => 1,
+       };
+       push @$cmd, '--namespace', "$namespace" if !$no_namespace_parameter->{$op};
+    }
     push @$cmd, '-c', $cmd_option->{ceph_conf} if ($cmd_option->{ceph_conf});
     push @$cmd, '-m', $cmd_option->{mon_host} if ($cmd_option->{mon_host});
     push @$cmd, '--auth_supported', $cmd_option->{auth_supported} if ($cmd_option->{auth_supported});
@@ -63,7 +73,7 @@ my $rados_cmd = sub {
 my $librados_connect = sub {
     my ($scfg, $storeid, $options) = @_;
 
-    my $librados_config = PVE::Storage::CephTools::ceph_connect_option($scfg, $storeid);
+    my $librados_config = PVE::CephConfig::ceph_connect_option($scfg, $storeid);
 
     my $rados = PVE::RADOS->new(%$librados_config);
 
@@ -71,55 +81,51 @@ my $librados_connect = sub {
 };
 
 # needed for volumes created using ceph jewel (or higher)
-my $krbd_feature_disable = sub {
+my $krbd_feature_update = sub {
     my ($scfg, $storeid, $name) = @_;
 
-    return 1 if !$scfg->{krbd};
+    my (@disable, @enable);
+    my ($kmajor, $kminor) = PVE::ProcFSTools::kernel_version();
 
-    my ($major, undef, undef, undef) = ceph_version();
-    return 1 if $major < 10;
-
-    my $krbd_feature_blacklist = ['deep-flatten', 'fast-diff', 'object-map', 'exclusive-lock'];
-    my (undef, undef, undef, undef, $features) = rbd_volume_info($scfg, $storeid, $name);
-
-    my $active_features = { map { $_ => 1 } @$features };
-    my $incompatible_features = join(',', grep { %$active_features{$_} } @$krbd_feature_blacklist);
-
-    if ($incompatible_features) {
-       my $feature_cmd = &$rbd_cmd($scfg, $storeid, 'feature', 'disable', $name, $incompatible_features);
-       run_rbd_command($feature_cmd, errmsg => "could not disable krbd-incompatible image features of rbd volume $name");
+    if ($kmajor > 5 || $kmajor == 5 && $kminor >= 3) {
+       # 'deep-flatten' can only be disabled, not enabled after image creation
+       push @enable, 'fast-diff', 'object-map';
+    } else {
+       push @disable, 'fast-diff', 'object-map', 'deep-flatten';
     }
-};
 
-my $ceph_version_parser = sub {
-    my $line = shift;
-    if ($line =~ m/^ceph version ((\d+)\.(\d+)\.(\d+))(?: \([a-fA-F0-9]+\))/) {
-       return ($2, $3, $4, $1);
+    if ($kmajor >= 5) {
+       push @enable, 'exclusive-lock';
     } else {
-       warn "Could not parse Ceph version: '$line'\n";
+       push @disable, 'exclusive-lock';
     }
-};
 
-sub ceph_version {
-    my ($cache) = @_;
+    my $active_features_list = (rbd_volume_info($scfg, $storeid, $name))[4];
+    my $active_features = { map { $_ => 1 } @$active_features_list };
 
-    my $version_string = $cache;
+    my $to_disable = join(',', grep {  $active_features->{$_} } @disable);
+    my $to_enable  = join(',', grep { !$active_features->{$_} } @enable );
 
-    my $major;
-    my $minor;
-    my $bugfix;
-
-    if (defined($version_string)) {
-       ($major, $minor, $bugfix, $version_string) = &$ceph_version_parser($version_string);
-    } else {
-       run_command('ceph --version', outfunc => sub {
-           my $line = shift;
-           ($major, $minor, $bugfix, $version_string) = &$ceph_version_parser($line);
-       });
+    if ($to_disable) {
+       print "disable RBD image features this kernel RBD drivers is not compatible with: $to_disable\n";
+       my $cmd = $rbd_cmd->($scfg, $storeid, 'feature', 'disable', $name, $to_disable);
+       run_rbd_command(
+           $cmd,
+           errmsg => "could not disable krbd-incompatible image features '$to_disable' for rbd image: $name",
+       );
     }
-    return undef if !defined($version_string);
-    return wantarray ? ($major, $minor, $bugfix, $version_string) : $version_string;
-}
+    if ($to_enable) {
+       print "enable RBD image features this kernel RBD drivers supports: $to_enable\n";
+       eval {
+           my $cmd = $rbd_cmd->($scfg, $storeid, 'feature', 'enable', $name, $to_enable);
+           run_rbd_command(
+               $cmd,
+               errmsg => "could not enable krbd-compatible image features '$to_enable' for rbd image: $name",
+           );
+       };
+       warn "$@" if $@;
+    }
+};
 
 sub run_rbd_command {
     my ($cmd, %args) = @_;
@@ -140,7 +146,7 @@ sub run_rbd_command {
            *STDERR->flush();
        };
     }
-    
+
     eval { run_command($cmd, %args); };
     if (my $err = $@) {
        die $errmsg . $lasterr if length($lasterr);
@@ -153,12 +159,13 @@ sub run_rbd_command {
 sub rbd_ls {
     my ($scfg, $storeid) = @_;
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'ls', '-l', '--format', 'json');
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
+    $pool .= "/$scfg->{namespace}" if defined($scfg->{namespace});
 
     my $raw = '';
     my $parser = sub { $raw .= shift };
 
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'ls', '-l', '--format', 'json');
     eval {
        run_rbd_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc => $parser);
     };
@@ -196,6 +203,38 @@ sub rbd_ls {
     return $list;
 }
 
+sub rbd_ls_snap {
+    my ($scfg, $storeid, $name) = @_;
+
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'ls', $name, '--format', 'json');
+
+    my $raw = '';
+    run_rbd_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc => sub { $raw .= shift; });
+
+    my $list;
+    if ($raw =~ m/^(\[.*\])$/s) { # untaint
+       $list = eval { JSON::decode_json($1) };
+       die "invalid JSON output from 'rbd snap ls $name': $@\n" if $@;
+    } else {
+       die "got unexpected data from 'rbd snap ls $name': '$raw'\n";
+    }
+
+    $list = [] if !defined($list);
+
+    my $res = {};
+    foreach my $el (@$list) {
+       my $snap = $el->{name};
+       my $protected = defined($el->{protected}) && $el->{protected} eq "true" ? 1 : undef;
+       $res->{$snap} = {
+           name => $snap,
+           id => $el->{id} // undef,
+           size => $el->{size} // 0,
+           protected => $protected,
+       };
+    }
+    return $res;
+}
+
 sub rbd_volume_info {
     my ($scfg, $storeid, $volname, $snap) = @_;
 
@@ -206,7 +245,7 @@ sub rbd_volume_info {
        push @options, '--snap', $snap;
     }
 
-    $cmd = &$rbd_cmd($scfg, $storeid, @options);
+    $cmd = $rbd_cmd->($scfg, $storeid, @options);
 
     my $raw = '';
     my $parser = sub { $raw .= shift };
@@ -250,6 +289,10 @@ sub properties {
            description => "Pool.",
            type => 'string',
        },
+       namespace => {
+           description => "RBD Namespace.",
+           type => 'string',
+       },
        username => {
            description => "RBD Id.",
            type => 'string',
@@ -259,7 +302,7 @@ sub properties {
            type => 'string',
        },
        krbd => {
-           description => "Access rbd through krbd kernel module.",
+           description => "Always access rbd through krbd kernel module.",
            type => 'boolean',
        },
     };
@@ -271,6 +314,7 @@ sub options {
        disable => { optional => 1 },
        monhost => { optional => 1},
        pool => { optional => 1 },
+       namespace => { optional => 1 },
        username => { optional => 1 },
        content => { optional => 1 },
        krbd => { optional => 1 },
@@ -285,7 +329,9 @@ sub on_add_hook {
 
     return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph
 
-    PVE::Storage::CephTools::ceph_create_keyfile($scfg->{type}, $storeid);
+    PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid);
+
+    return;
 }
 
 sub on_delete_hook {
@@ -293,7 +339,9 @@ sub on_delete_hook {
 
     return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph
 
-    PVE::Storage::CephTools::ceph_remove_keyfile($scfg->{type}, $storeid);
+    PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid);
+
+    return;
 }
 
 sub parse_volname {
@@ -309,18 +357,18 @@ sub parse_volname {
 sub path {
     my ($class, $scfg, $volname, $storeid, $snapname) = @_;
 
-    my $cmd_option = PVE::Storage::CephTools::ceph_connect_option($scfg, $storeid);
+    my $cmd_option = PVE::CephConfig::ceph_connect_option($scfg, $storeid);
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
     $name .= '@'.$snapname if $snapname;
 
-    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
-    return ("/dev/rbd/$pool/$name", $vmid, $vtype) if $scfg->{krbd};
+    my $rbd_path = get_rbd_path($scfg, $name);
+    return ("/dev/rbd/${rbd_path}", $vmid, $vtype) if $scfg->{krbd};
 
-    my $path = "rbd:$pool/$name";
+    my $path = "rbd:${rbd_path}";
 
     $path .= ":conf=$cmd_option->{ceph_conf}" if $cmd_option->{ceph_conf};
     if (defined($scfg->{monhost})) {
-       my $monhost = PVE::Storage::CephTools::hostlist($scfg->{monhost}, ';');
+       my $monhost = PVE::CephConfig::hostlist($scfg->{monhost}, ';');
        $monhost =~ s/:/\\:/g;
        $path .= ":mon_host=$monhost";
        $path .= ":auth_supported=$cmd_option->{auth_supported}";
@@ -331,10 +379,11 @@ sub path {
     return ($path, $vmid, $vtype);
 }
 
-my $find_free_diskname = sub {
-    my ($storeid, $scfg, $vmid) = @_;
+sub find_free_diskname {
+    my ($class, $storeid, $scfg, $vmid, $fmt, $add_fmt_suffix) = @_;
+
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'ls');
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'ls');
     my $disk_list = [];
 
     my $parser = sub {
@@ -352,7 +401,7 @@ my $find_free_diskname = sub {
     die $err if $err && $err !~ m/doesn't contain rbd images/;
 
     return PVE::Storage::Plugin::get_next_vm_diskname($disk_list, $storeid, $vmid, undef, $scfg);
-};
+}
 
 sub create_base {
     my ($class, $storeid, $scfg, $volname) = @_;
@@ -377,7 +426,13 @@ sub create_base {
 
     my $newvolname = $basename ? "$basename/$newname" : "$newname";
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'rename', &$add_pool_to_disk($scfg, $name), &$add_pool_to_disk($scfg, $newname));
+    my $cmd = $rbd_cmd->(
+       $scfg,
+       $storeid,
+       'rename',
+       get_rbd_path($scfg, $name),
+       get_rbd_path($scfg, $newname),
+    );
     run_rbd_command($cmd, errmsg => "rbd rename '$name' error");
 
     my $running  = undef; #fixme : is create_base always offline ?
@@ -387,7 +442,7 @@ sub create_base {
     my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $newname, $snap);
 
     if (!$protected){
-       my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'protect', $newname, '--snap', $snap);
+       my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'protect', $newname, '--snap', $snap);
        run_rbd_command($cmd, errmsg => "rbd protect $newname snap '$snap' error");
     }
 
@@ -407,7 +462,7 @@ sub clone_image {
     die "$volname is not a base image and snapname is not provided\n" 
        if !$isBase && !length($snapname);
 
-    my $name = $find_free_diskname->($storeid, $scfg, $vmid);
+    my $name = $class->find_free_diskname($storeid, $scfg, $vmid);
 
     warn "clone $volname: $basename snapname $snap to $name\n";
 
@@ -415,7 +470,7 @@ sub clone_image {
        my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $volname, $snapname);
 
        if (!$protected) {
-           my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'protect', $volname, '--snap', $snapname);
+           my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'protect', $volname, '--snap', $snapname);
            run_rbd_command($cmd, errmsg => "rbd protect $volname snap $snapname error");
        }
     }
@@ -423,13 +478,18 @@ sub clone_image {
     my $newvol = "$basename/$name";
     $newvol = $name if length($snapname);
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'clone', &$add_pool_to_disk($scfg, $basename), 
-                       '--snap', $snap, &$add_pool_to_disk($scfg, $name));
+    my $cmd = $rbd_cmd->(
+       $scfg,
+       $storeid,
+       'clone',
+       get_rbd_path($scfg, $basename),
+       '--snap',
+       $snap,
+       get_rbd_path($scfg, $name),
+    );
 
     run_rbd_command($cmd, errmsg => "rbd clone '$basename' error");
 
-    &$krbd_feature_disable($scfg, $storeid, $name);
-
     return $newvol;
 }
 
@@ -440,12 +500,10 @@ sub alloc_image {
     die "illegal name '$name' - should be 'vm-$vmid-*'\n"
        if  $name && $name !~ m/^vm-$vmid-/;
 
-    $name = $find_free_diskname->($storeid, $scfg, $vmid) if !$name;
+    $name = $class->find_free_diskname($storeid, $scfg, $vmid) if !$name;
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'create', '--image-format' , 2, '--size', int(($size+1023)/1024), $name);
-    run_rbd_command($cmd, errmsg => "rbd create $name' error");
-
-    &$krbd_feature_disable($scfg, $storeid, $name);
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'create', '--image-format' , 2, '--size', int(($size+1023)/1024), $name);
+    run_rbd_command($cmd, errmsg => "rbd create '$name' error");
 
     return $name;
 }
@@ -456,21 +514,21 @@ sub free_image {
     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);
+
+    my $snaps = rbd_ls_snap($scfg, $storeid, $name);
+    foreach my $snap (keys %$snaps) {
+       if ($snaps->{$snap}->{protected}) {
+           my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'unprotect', $name, '--snap', $snap);
            run_rbd_command($cmd, errmsg => "rbd unprotect $name snap '$snap' error");
        }
     }
 
     $class->deactivate_volume($storeid, $scfg, $volname);
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge',  $name);
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'purge',  $name);
     run_rbd_command($cmd, errmsg => "rbd snap purge '$volname' error");
 
-    $cmd = &$rbd_cmd($scfg, $storeid, 'rm', $name);
+    $cmd = $rbd_cmd->($scfg, $storeid, 'rm', $name);
     run_rbd_command($cmd, errmsg => "rbd rm '$volname' error");
 
     return undef;
@@ -480,46 +538,40 @@ sub list_images {
     my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
 
     $cache->{rbd} = rbd_ls($scfg, $storeid) if !$cache->{rbd};
-    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
-
-    my $res = [];
-
-    if (my $dat = $cache->{rbd}->{$pool}) {
-       foreach my $image (keys %$dat) {
 
-           my $info = $dat->{$image};
+    my $dat = $cache->{rbd}->{get_rbd_path($scfg)};
+    return [] if !$dat; # nothing found
 
-           my $volname = $info->{name};
-           my $parent = $info->{parent};
-           my $owner = $info->{vmid};
-
-           if ($parent && $parent =~ m/^(base-\d+-\S+)\@__base__$/) {
-               $info->{volid} = "$storeid:$1/$volname";
-           } else {
-               $info->{volid} = "$storeid:$volname";
-           }
+    my $res = [];
+    for my $image (sort keys %$dat) {
+       my $info = $dat->{$image};
+       my ($volname, $parent, $owner) = $info->@{'name', 'parent', 'vmid'};
+
+       if ($parent && $parent =~ m/^(base-\d+-\S+)\@__base__$/) {
+           $info->{volid} = "$storeid:$1/$volname";
+       } else {
+           $info->{volid} = "$storeid:$volname";
+       }
 
-           if ($vollist) {
-               my $found = grep { $_ eq $info->{volid} } @$vollist;
-               next if !$found;
-           } else {
-               next if defined ($vmid) && ($owner ne $vmid);
-           }
+       if ($vollist) {
+           my $found = grep { $_ eq $info->{volid} } @$vollist;
+           next if !$found;
+       } else {
+           next if defined ($vmid) && ($owner ne $vmid);
+       }
 
-           $info->{format} = 'raw';
+       $info->{format} = 'raw';
 
-           push @$res, $info;
-       }
+       push @$res, $info;
     }
-    
+
     return $res;
 }
 
 sub status {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-
-    my $rados = &$librados_connect($scfg, $storeid);
+    my $rados = $librados_connect->($scfg, $storeid);
     my $df = $rados->mon_command({ prefix => 'df', format => 'json' });
 
     my ($d) = grep { $_->{name} eq $scfg->{pool} } @{$df->{pools}};
@@ -527,7 +579,7 @@ sub status {
     # max_avail -> max available space for data w/o replication in the pool
     # bytes_used -> data w/o replication in the pool
     my $free = $d->{stats}->{max_avail};
-    my $used = $d->{stats}->{bytes_used};
+    my $used = $d->{stats}->{stored} // $d->{stats}->{bytes_used};
     my $total = $used + $free;
     my $active = 1;
 
@@ -544,39 +596,60 @@ sub deactivate_storage {
     return 1;
 }
 
-sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+my sub get_kernel_device_path {
+    my ($scfg, $name) = @_;
+    return "/dev/rbd/" . get_rbd_path($scfg, $name);
+};
 
-    return 1 if !$scfg->{krbd};
+sub map_volume {
+    my ($class, $storeid, $scfg, $volname, $snapname) = @_;
 
-    my ($vtype, $name, $vmid) = $class->parse_volname($volname);
-    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
+    my ($vtype, $img_name, $vmid) = $class->parse_volname($volname);
+
+    my $name = $img_name;
+    $name .= '@'.$snapname if $snapname;
 
-    my $path = "/dev/rbd/$pool/$name";
-    $path .= '@'.$snapname if $snapname;
-    return if -b $path;
+    my $kerneldev = get_kernel_device_path($scfg, $name);
 
+    return $kerneldev if -b $kerneldev; # already mapped
+
+    # features can only be enabled/disabled for image, not for snapshot!
+    $krbd_feature_update->($scfg, $storeid, $img_name);
+
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'map', $name);
+    run_rbd_command($cmd, errmsg => "can't map rbd volume $name");
+
+    return $kerneldev;
+}
+
+sub unmap_volume {
+    my ($class, $storeid, $scfg, $volname, $snapname) = @_;
+
+    my ($vtype, $name, $vmid) = $class->parse_volname($volname);
     $name .= '@'.$snapname if $snapname;
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'map', $name);
-    run_rbd_command($cmd, errmsg => "can't mount rbd volume $name");
+
+    my $kerneldev = get_kernel_device_path($scfg, $name);
+
+    if (-b $kerneldev) {
+       my $cmd = $rbd_cmd->($scfg, $storeid, 'unmap', $kerneldev);
+       run_rbd_command($cmd, errmsg => "can't unmap rbd device $kerneldev");
+    }
 
     return 1;
 }
 
-sub deactivate_volume {
+sub activate_volume {
     my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
-    return 1 if !$scfg->{krbd};
+    $class->map_volume($storeid, $scfg, $volname, $snapname) if $scfg->{krbd};
 
-    my ($vtype, $name, $vmid) = $class->parse_volname($volname);
-    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
+    return 1;
+}
 
-    my $path = "/dev/rbd/$pool/$name";
-    $path .= '@'.$snapname if $snapname;
-    return if ! -b $path;
+sub deactivate_volume {
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'unmap', $path);
-    run_rbd_command($cmd, errmsg => "can't unmap rbd volume $name");
+    $class->unmap_volume($storeid, $scfg, $volname, $snapname);
 
     return 1;
 }
@@ -592,11 +665,11 @@ sub volume_size_info {
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
 
-    return 1 if $running && !$scfg->{krbd};
+    return 1 if $running && !$scfg->{krbd}; # FIXME???
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'resize', '--allow-shrink', '--size', ($size/1024/1024), $name);
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'resize', '--allow-shrink', '--size', ($size/1024/1024), $name);
     run_rbd_command($cmd, errmsg => "rbd resize '$volname' error");
     return undef;
 }
@@ -606,7 +679,7 @@ sub volume_snapshot {
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'create', '--snap', $snap, $name);
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'create', '--snap', $snap, $name);
     run_rbd_command($cmd, errmsg => "rbd snapshot '$volname' error");
     return undef;
 }
@@ -616,14 +689,14 @@ sub volume_snapshot_rollback {
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'rollback', '--snap', $snap, $name);
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'rollback', '--snap', $snap, $name);
     run_rbd_command($cmd, errmsg => "rbd snapshot $volname to '$snap' error");
 }
 
 sub volume_snapshot_delete {
     my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
 
-    return 1 if $running && !$scfg->{krbd};
+    return 1 if $running && !$scfg->{krbd}; # FIXME: ????
 
     $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
 
@@ -631,17 +704,21 @@ sub volume_snapshot_delete {
 
     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);
+       my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'unprotect', $name, '--snap', $snap);
        run_rbd_command($cmd, errmsg => "rbd unprotect $name snap '$snap' error");
     }
 
-    my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'rm', '--snap', $snap, $name);
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'rm', '--snap', $snap, $name);
 
     run_rbd_command($cmd, errmsg => "rbd snapshot '$volname' error");
 
     return undef;
 }
 
+sub volume_snapshot_needs_fsfreeze {
+    return 1;
+}
+
 sub volume_has_feature {
     my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
 
@@ -653,14 +730,13 @@ sub volume_has_feature {
        sparseinit => { base => 1, current => 1},
     };
 
-    my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
-        $class->parse_volname($volname);
+    my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) = $class->parse_volname($volname);
 
     my $key = undef;
-    if($snapname){
+    if ($snapname){
        $key = 'snap';
-    }else{
-       $key =  $isBase ? 'base' : 'current';
+    } else {
+       $key = $isBase ? 'base' : 'current';
     }
     return 1 if $features->{$feature}->{$key};