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@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.gruenbich...@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 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel