Am 06.05.25 um 13:07 schrieb Fabian Grünbichler: >>> @@ -580,15 +593,7 @@ sub clone_image { >>> >>> warn "clone $volname: $basename snapname $snap to $name\n"; >>> >>> - if (length($snapname)) { >>> - my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, >>> $volname, $snapname); >>> - >>> - if (!$protected) { >>> - my $snap_spec = get_rbd_path($scfg, $volname, $snapname); >>> - my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'protect', >>> $snap_spec); >>> - run_rbd_command($cmd, errmsg => "rbd protect '$snap_spec' error"); >>> - } >>> - } >>> + rbd_protect_snap($scfg, $storeid, $volname, $snap) if >>> length($snapname); >> >> Last argument should be $snapname > > not really - this is saying "protect the snapshot $snap if it is not the > (already protected) '__base__' snapshot". probably the whole logic > should be adapted to make this explicit though, e.g., something like:
Oh right, it doesn't matter semantically, because there is $snap = $snapname if length $snapname; further above. I just compared with the old code that used $snapname as the argument, which you don't anymore. > diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm > index 6604bc3..5c1a8e2 100644 > --- a/src/PVE/Storage/RBDPlugin.pm > +++ b/src/PVE/Storage/RBDPlugin.pm > @@ -580,23 +580,26 @@ sub create_base { > sub clone_image { > my ($class, $scfg, $storeid, $volname, $vmid, $snapname) = @_; > > - my $snap = '__base__'; > - $snap = $snapname if length $snapname; > - > my ($vtype, $basename, $basevmid, undef, undef, $isBase) = > $class->parse_volname($volname); > > - die "$volname is not a base image and snapname is not provided\n" > - if !$isBase && !length($snapname); > + my $snap; > + > + if ($snapname) { > + $snap = $snapname; > + } elsif ($isBase) { > + $snap = '__base__'; > + } else { > + die "$volname is not a base image and snapname is not provided\n"; > + } > > my $name = $class->find_free_diskname($storeid, $scfg, $vmid); > > warn "clone $volname: $basename snapname $snap to $name\n"; > > - rbd_protect_snap($scfg, $storeid, $volname, $snap) if length($snapname); > + rbd_protect_snap($scfg, $storeid, $volname, $snap) if $snap ne > '__base__'; > > - my $newvol = "$basename/$name"; > - $newvol = $name if length($snapname); > + my $newvol = $snapname ? $name : "$basename/$name"; > > my @options = ( > get_rbd_path($scfg, $basename, $snap), > Looks fine to me at a glance. _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel