[PATCH pve-storage v1 38/54] test: list volumes: document behavior wrt. undeclared content types

Max R. Carrara
2026-04-22T11:19:16Z

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.

Document this through a test case.

Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
src/test/list_volumes_test.pm | 109 ++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)

diff --git a/src/test/list_volumes_test.pm b/src/test/list_volumes_test.pm
index ca3bbac7..455fb227 100644
--- a/src/test/list_volumes_test.pm
+++ b/src/test/list_volumes_test.pm
@@ -909,6 +909,115 @@ 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 => {
+ content => 'images',
+ ctime => $DEFAULT_CTIME,
+ format => 'qcow2',
+ parent => undef,
+ size => $DEFAULT_SIZE,
+ used => $DEFAULT_USED,
+ vmid => '16110',
+ volid => 'local:16110/vm-16110-disk-0.qcow2',
+ },
+ },
+ {
+ file => "$DEFAULT_STORAGE_PATH/images/1234/vm-1234-disk-0.qcow2",
+ parent => '../ssss/base-4321-disk-0.qcow2',
+ expected => {
+ content => 'images',
+ ctime => $DEFAULT_CTIME,
+ format => 'qcow2',
+ parent => '../ssss/base-4321-disk-0.qcow2',
+ size => $DEFAULT_SIZE,
+ used => $DEFAULT_USED,
+ vmid => '1234',
+ volid => 'local:1234/vm-1234-disk-0.qcow2',
+ },
+ },
+ {
+ file => "$DEFAULT_STORAGE_PATH/images/16112/vm-16112-disk-0.raw",
+ expected => {
+ content => 'rootdir',
+ ctime => $DEFAULT_CTIME,
+ format => 'raw',
+ parent => undef,
+ size => $DEFAULT_SIZE,
+ used => $DEFAULT_USED,
+ vmid => '16112',
+ volid => 'local:16112/vm-16112-disk-0.raw',
+ },
+ },
+ {
+ file =>
+ "$DEFAULT_STORAGE_PATH/template/cache/alpine-3.10-default_20190626_amd64.tar.xz",
+ expected => {
+ content => 'vztmpl',
+ ctime => $DEFAULT_CTIME,
+ format => 'txz',
+ size => $DEFAULT_SIZE,
+ volid => 'local:vztmpl/alpine-3.10-default_20190626_amd64.tar.xz',
+ },
+ },
+ {
+ file => "$DEFAULT_STORAGE_PATH/template/iso/archlinux-2020.02.01-x86_64.iso",
+ expected => {
+ content => 'iso',
+ ctime => $DEFAULT_CTIME,
+ format => 'iso',
+ size => $DEFAULT_SIZE,
+ volid => 'local:iso/archlinux-2020.02.01-x86_64.iso',
+ },
+ },
+ {
+ file =>
+ "$DEFAULT_STORAGE_PATH/dump/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo",
+ expected => {
+ content => 'backup',
+ ctime => 1585604370,
+ format => 'tar.lzo',
+ size => $DEFAULT_SIZE,
+ subtype => 'lxc',
+ vmid => '16112',
+ volid => 'local:backup/vzdump-lxc-16112-2020_03_30-21_39_30.tar.lzo',
+ },
+ },
+ {
+ file => "$DEFAULT_STORAGE_PATH/snippets/hookscript.pl",
+ expected => {
+ content => 'snippets',
+ ctime => $DEFAULT_CTIME,
+ format => 'snippet',
+ size => $DEFAULT_SIZE,
+ volid => 'local:snippets/hookscript.pl',
+ },
+ },
+ {
+ file => "$DEFAULT_STORAGE_PATH/import/import.ova",
+ expected => {
+ content => 'import',
+ ctime => $DEFAULT_CTIME,
+ format => 'ova',
+ size => $DEFAULT_SIZE,
+ volid => 'local:import/import.ova',
+ },
+ },
+ ],
+ },
];

# provide static vmlist for tests
--
2.47.3