[PATCH pve-storage v1 33/54] plugin: use parsing helper in parse_volume_id sub

Max R. Carrara
2026-04-22T11:17:17Z

In order to avoid having multiple subroutines do (sort of) the same
thing, use the `parse_volid_as_parts()` parsing function inside the
`parse_volume_id()` plugin API sub.

Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
src/PVE/Storage/Plugin.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 65e0869b..3853682b 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -22,6 +22,7 @@ use PVE::Storage::Common qw(
use PVE::Storage::Common::Parse qw(
parse_volname_as_parts
parse_path_as_volid_parts
+ parse_volid_as_parts
);

use JSON;
@@ -428,8 +429,8 @@ PVE::JSONSchema::register_format('pve-volume-id', \&parse_volume_id);
sub parse_volume_id {
my ($volid, $noerr) = @_;

- if ($volid =~ m/^([a-z][a-z0-9\-\_\.]*[a-z0-9]):(.+)$/i) {
- return wantarray ? ($1, $2) : $1;
+ if (defined(my $parts = parse_volid_as_parts($volid))) {
+ return wantarray ? ($parts->{storeid}, $parts->{volname}) : $parts->{storeid};
}
return undef if $noerr;
die "unable to parse volume ID '$volid'\n";
--
2.47.3