From ccc3bae30a87d7c0a634698a28d826623ef88c57 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Fri, 6 Dec 2024 17:25:37 +0100 Subject: [PATCH] api: check storage access: import: use checked_parse_volname Use the same logic as the actual import later. Has the nice side effect of getting rid of the unnecessary manual dispatch to the plugin too. Signed-off-by: Fiona Ebner --- PVE/API2/Qemu.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 0dd52b33..fb192760 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -164,11 +164,11 @@ my $check_storage_access = sub { if (my $src_image = $drive->{'import-from'}) { my $src_vmid; - my ($storeid, $volname) = PVE::Storage::parse_volume_id($src_image, 1); + my ($storeid) = PVE::Storage::parse_volume_id($src_image, 1); if ($storeid) { # PVE-managed volume my $scfg = PVE::Storage::storage_config($storecfg, $storeid); - my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); - (my $vtype, undef, $src_vmid, undef, undef, undef, my $fmt) = $plugin->parse_volname($volname); + (my $vtype, undef, $src_vmid, undef, undef, undef, my $fmt) + = checked_parse_volname($storecfg, $src_image); raise_param_exc({ $ds => "$src_image has wrong type '$vtype' - needs to be 'images' or 'import'" }) if $vtype ne 'images' && $vtype ne 'import';