[pve-devel] [PATCH storage 1/3] rbd: extend get_rbd_(dev_)path helpers with $snap parameter
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Apr 23 15:59:02 CEST 2025
this helper effectively converts a storage config entry and a
volume/image name into an RBD image-spec as specified in rbd(8):
image-spec is [pool-name/[namespace-name/]]image-name
by extending it with an optional $snap parameter it can also convert to
a snap-spec:
snap-spec is [pool-name/[namespace-name/]]image-name at snap-name
this is a needed preparatory step for dropping the (mostly) deprecated
`--pool ..`, `--namespace ..` and `--snap ..` parameters when invoking
the `rbd` CLI tool.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/PVE/Storage/RBDPlugin.pm | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
index 73bc97e..8c67a37 100644
--- a/src/PVE/Storage/RBDPlugin.pm
+++ b/src/PVE/Storage/RBDPlugin.pm
@@ -42,15 +42,16 @@ my $librados_connect = sub {
};
my sub get_rbd_path {
- my ($scfg, $volume) = @_;
+ my ($scfg, $volume, $snap) = @_;
my $path = $scfg->{pool} ? $scfg->{pool} : 'rbd';
$path .= "/$scfg->{namespace}" if defined($scfg->{namespace});
$path .= "/$volume" if defined($volume);
+ $path .= "\@$snap" if defined($snap);
return $path;
};
my sub get_rbd_dev_path {
- my ($scfg, $storeid, $volume) = @_;
+ my ($scfg, $storeid, $volume, $snap) = @_;
my $cluster_id = '';
if ($scfg->{fsid}) {
@@ -70,7 +71,7 @@ my sub get_rbd_dev_path {
die "cluster fsid has invalid format\n";
}
- my $rbd_path = get_rbd_path($scfg, $volume);
+ my $rbd_path = get_rbd_path($scfg, $volume, $snap);
my $pve_path = "/dev/rbd-pve/${cluster_id}/${rbd_path}";
my $path = "/dev/rbd/${rbd_path}";
--
2.39.5
More information about the pve-devel
mailing list