To prevent an error when disabling features of a rbd image with already
disabled flags. This aborted the CT/VM cloning halfway through with
a leftover rbd image, but no vmid.conf to it.

Signed-off-by: Alwin Antreich <a.antre...@proxmox.com>
---
 PVE/Storage/RBDPlugin.pm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 2ca14ef..06e0a0a 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -109,8 +109,16 @@ my $krdb_feature_disable = sub {
     my ($major, undef, undef, undef) = ceph_version();
     return 1 if $major < 10;

-    my $feature_cmd = &$rbd_cmd($scfg, $storeid, 'feature', 'disable', $name, 
'deep-flatten,fast-diff,object-map,exclusive-lock');
-    run_rbd_command($feature_cmd, errmsg => "could not disable 
krbd-incompatible image features of rbd volume $name");
+    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 } PVE::Tools::split_list($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");
+    }
 };

 my $ceph_version_parser = sub {
@@ -221,6 +229,7 @@ sub rbd_volume_info {
     my $parent = undef;
     my $format = undef;
     my $protected = undef;
+    my $features = undef;

     my $parser = sub {
        my $line = shift;
@@ -233,13 +242,15 @@ sub rbd_volume_info {
            $format = $1;
        } elsif ($line =~ m/protected:\s(\S+)/) {
            $protected = 1 if $1 eq "True";
+       } elsif ($line =~ m/features:\s(.+)/) {
+           $features = $1;
        }

     };

     run_rbd_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc => 
$parser);

-    return ($size, $parent, $format, $protected);
+    return ($size, $parent, $format, $protected, $features);
 }

 # Configuration
--
2.11.0


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to