From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 45A911FF13B for ; Wed, 22 Apr 2026 13:15:44 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BE79317C03; Wed, 22 Apr 2026 13:14:27 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v1 15/54] storage: heave vtype file path parsing logic inside loop into helper Date: Wed, 22 Apr 2026 13:12:41 +0200 Message-ID: <20260422111322.257380-16-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260422111322.257380-1-m.carrara@proxmox.com> References: <20260422111322.257380-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776856331162 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.085 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: Y2KEMHWQFRS2OFVF6Q44ZNEUWQXFJTIL X-Message-ID-Hash: Y2KEMHWQFRS2OFVF6Q44ZNEUWQXFJTIL X-MailFrom: m.carrara@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Max R. Carrara --- src/PVE/Storage.pm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index e9b0cb7e..2886ab9e 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -712,10 +712,9 @@ sub path_to_volume_id { # for example when nfs storage is not mounted $path = abs_path($path) || $path; - for my $sid (keys $ids->%*) { - my $scfg = $ids->{$sid}; - next if !$scfg->{path}; - my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + my $parse_volid_from_file_path = sub { + my ($plugin, $sid, $scfg) = @_; + my $imagedir = plugin_get_vtype_subdir($scfg, 'images'); my $isodir = plugin_get_vtype_subdir($scfg, 'iso'); my $tmpldir = plugin_get_vtype_subdir($scfg, 'vztmpl'); @@ -763,6 +762,17 @@ sub path_to_volume_id { my $name = $1; return ('import', "$sid:import/$name"); } + + return (''); + }; + + for my $sid (keys $ids->%*) { + my $scfg = $ids->{$sid}; + next if !$scfg->{path}; + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + + my ($vtype, $volid) = $parse_volid_from_file_path->($plugin, $sid, $scfg); + return ($vtype, $volid) if $vtype; } # can't map path to volume id -- 2.47.3