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 2A4C31FF0AA for ; Tue, 17 Nov 2026 21:45:08 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2836D2180D; Tue, 17 Nov 2026 21:43:47 +0100 (CET) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v3 33/51] plugin: do not return volumes of undeclared content types anymore Date: Tue, 17 Nov 2026 21:39:05 +0100 Message-ID: <20261117203953.913035-34-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261117203953.913035-1-m.carrara@proxmox.com> References: <20261117203953.913035-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: 1794948062799 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.249 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: FSV2SCL6J5WFACVDRLHSEVFZ43SBJHPN X-Message-ID-Hash: FSV2SCL6J5WFACVDRLHSEVFZ43SBJHPN 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 CC: Wolfgang Bumiller 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 test cases. Signed-off-by: Max R. Carrara --- src/PVE/Storage/Plugin.pm | 9 ++++++- src/test/list_volumes_test.pm | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index 0d44224f..c1569314 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -14,10 +14,13 @@ use File::stat qw(); use PVE::Tools qw(run_command); use PVE::JSONSchema qw(get_standard_option register_standard_option); use PVE::Cluster qw(cfs_register_file); use PVE::Storage::Common qw( + is_guest_vtype + content_allows + plugin_get_default_vtype_subdirs plugin_get_vtype_subdir ); use PVE::Storage::Common::Parse qw( parse_volname_as_parts @@ -1985,11 +1988,15 @@ sub list_volumes { my $vmlist = PVE::Cluster::get_vmlist(); my $get_raw_volumes_for_type = sub { my ($type) = @_; - if ($type eq 'images' || $type eq 'rootdir') { + if (!$scfg->{content} || !content_allows($scfg->{content}, $type)) { + return []; + } + + if (is_guest_vtype($type) || $type eq 'rootdir') { return $class->list_images($storeid, $scfg, $vmid); } return if !$scfg->{path}; diff --git a/src/test/list_volumes_test.pm b/src/test/list_volumes_test.pm index 65fc7629..adc6d563 100644 --- a/src/test/list_volumes_test.pm +++ b/src/test/list_volumes_test.pm @@ -1030,10 +1030,60 @@ my $test_param_list = [ volid => 'local:import/raw.raw.raw.your-boat.ova', }, }, ], }, + { + description => + "VMID: none, volume info is not 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 my $mock_cluster = Test::MockModule->new('PVE::Cluster', no_auto => 1); $mock_cluster->redefine(get_vmlist => sub { return $mocked_vmlist; }); -- 2.47.3