From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id D17B31FF0AB for ; Wed, 23 Sep 2026 17:11:54 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9FCA821809; Wed, 23 Sep 2026 17:10:09 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v2 34/50] plugin: do not return volumes of undeclared content types anymore Date: Wed, 23 Sep 2026 17:05:48 +0200 Message-ID: <20260923150606.531239-35-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260923150606.531239-1-m.carrara@proxmox.com> References: <20260923150606.531239-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: 1790176037990 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.401 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: 5MWMJUIYSTNET5CSHZE2ZMFXAGIVRIME X-Message-ID-Hash: 5MWMJUIYSTNET5CSHZE2ZMFXAGIVRIME 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: Currently, any content types / volume types that are passed to `PVE::Storage::Plugin->list_volumes()` are still taken into account by the method, even if the passed storage config does not declare them in its `content` key. In other words, the `content` property is ignored when listing volumes through `list_volumes()`. Or to express this more explicitly, consider a directory storage with `path` set to `/mnt/example` and `content` set to `iso,vztmpl`. Now, if there are files in `/mnt/example/snippets` for some reason and the `list_volumes()` method is called with `['snippets']` for the volume type list parameter, then the volume info hashes for the files in `/mnt/example/snippets` are included in the output. There is not really any use case for this behavior, and to my knowledge, it is also not something that we rely on. Therefore, instead of returning volumes for undeclared content types, return an empty list for that type. Document this new behavior through a test case. Signed-off-by: Max R. Carrara --- src/PVE/Storage/Plugin.pm | 4 +++ src/test/list_volumes_test.pm | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index def9e495..0047bc5b 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -1810,6 +1810,10 @@ sub list_volumes { my $get_raw_volumes_for_type = sub { my ($type) = @_; + if (!$scfg->{content}->{$type}) { + return []; + } + if ($type eq 'images' || $type eq 'rootdir') { return $class->list_images($storeid, $scfg, $vmid); } diff --git a/src/test/list_volumes_test.pm b/src/test/list_volumes_test.pm index ca3bbac7..1b9be6c5 100644 --- a/src/test/list_volumes_test.pm +++ b/src/test/list_volumes_test.pm @@ -909,6 +909,56 @@ my $test_param_list = [ }, ], }, + { + description => + "VMID: none, volume info is still returned for content types that are not declared", + storeid => $DEFAULT_STOREID, + scfg => { + type => 'dir', + path => $DEFAULT_STORAGE_PATH, + shared => 0, + content => {}, # note how no content types are declared here + }, + vmid => undef, + vtypes => ['images', 'rootdir', 'vztmpl', 'iso', 'backup', 'snippets', 'import'], + cases => [ + { + file => "$DEFAULT_STORAGE_PATH/images/16110/vm-16110-disk-0.qcow2", + expected => undef, + }, + { + file => "$DEFAULT_STORAGE_PATH/images/1234/vm-1234-disk-0.qcow2", + parent => '../ssss/base-4321-disk-0.qcow2', + expected => undef, + }, + { + file => "$DEFAULT_STORAGE_PATH/images/16112/vm-16112-disk-0.raw", + expected => undef, + }, + { + file => + "$DEFAULT_STORAGE_PATH/template/cache/alpine-3.10-default_20190626_amd64.tar.xz", + expected => undef, + }, + { + file => "$DEFAULT_STORAGE_PATH/template/iso/archlinux-2020.02.01-x86_64.iso", + expected => undef, + }, + { + file => + "$DEFAULT_STORAGE_PATH/dump/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo", + expected => undef, + }, + { + file => "$DEFAULT_STORAGE_PATH/snippets/hookscript.pl", + expected => undef, + }, + { + file => "$DEFAULT_STORAGE_PATH/import/import.ova", + expected => undef, + }, + ], + }, ]; # provide static vmlist for tests -- 2.47.3