* [PATCH storage] fix #8212: plugin: allow activating storages with content type 'none'
@ 2026-11-12 4:44 Lucas Barros
0 siblings, 0 replies; only message in thread
From: Lucas Barros @ 2026-11-12 4:44 UTC (permalink / raw)
To: pve-devel
Since the check that all content dirs are pairwise unequal was added,
activating a directory based storage looks up the content dir of every
configured content type. 'none' does not have one, so get_subdir() dies
and such a storage can neither be added nor activated:
# pvesm add dir test --path /mnt/test --content none
create storage failed: unknown vtype 'none'
Skip content types without a content dir in that check, they cannot
collide with any other content dir anyway.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
Reproduced on a PVE 9 node (libpve-storage-perl 9.1.15):
before:
$ pvesm add dir t8212 --path /mnt/t8212 --content none
create storage failed: unknown vtype 'none'
after:
$ pvesm add dir t8212 --path /mnt/t8212 --content none
$ pvesm status --storage t8212
Name Type Status Total (KiB) Used (KiB) Available (KiB) %
t8212 dir active 32815812 11878620 19553812 36.20%
Switching the content to 'iso' and back to 'none', and 'pvesm list',
work as well.
The new test fails without the change to Plugin.pm (unknown vtype
'none') and passes with it. 'make test' passes before and after (the
plugin tests go from 567 to 570). proxmox-perltidy reports no changes.
The check was added in commit 5f4b5bd ("content-dirs: check that all
content dirs are pairwise inequal").
This patch was prepared with the help of an LLM based coding assistant;
I reviewed the change and ran the tests mentioned above myself.
src/PVE/Storage/Plugin.pm | 1 +
src/test/activate_storage_test.pm | 55 +++++++++++++++++++++++++++++++
src/test/run_plugin_tests.pl | 1 +
3 files changed, 57 insertions(+)
create mode 100644 src/test/activate_storage_test.pm
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index e4ad7e6..2d1e706 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -2124,6 +2124,7 @@ sub activate_storage {
# check that content dirs are pairwise inequal
my $resolved_subdirs = {};
for my $vtype (sort keys $scfg->{content}->%*) {
+ next if !exists($vtype_subdirs->{$vtype}); # e.g. 'none' has no content dir
my $subdir = $class->get_subdir($scfg, $vtype);
my $abs_subdir = abs_path($subdir);
next if !defined($abs_subdir);
diff --git a/src/test/activate_storage_test.pm b/src/test/activate_storage_test.pm
new file mode 100644
index 0000000..5112f5e
--- /dev/null
+++ b/src/test/activate_storage_test.pm
@@ -0,0 +1,55 @@
+package PVE::Storage::TestActivateStorage;
+
+use strict;
+use warnings;
+
+use lib qw(..);
+
+use File::Temp qw(tempdir);
+use Test::More;
+
+use PVE::Storage::Plugin;
+
+my $tests = [
+ {
+ description => "content type 'none' has no content dir",
+ content => { none => 1 },
+ expected_dirs => [],
+ },
+ {
+ description => 'content dirs are created',
+ content => { iso => 1, vztmpl => 1 },
+ expected_dirs => ['template/iso', 'template/cache'],
+ },
+ {
+ description => 'same content dir for multiple content types',
+ content => { iso => 1, vztmpl => 1 },
+ 'content-dirs' => { iso => 'shared', vztmpl => 'shared' },
+ expected_error => qr/uses directory .* for multiple content types/,
+ },
+];
+
+plan tests => scalar($tests->@*);
+
+for my $test ($tests->@*) {
+ my $path = tempdir(CLEANUP => 1);
+ my $scfg = { path => $path, content => $test->{content} };
+ $scfg->{'content-dirs'} = $test->{'content-dirs'} if $test->{'content-dirs'};
+
+ eval { PVE::Storage::Plugin->activate_storage('test', $scfg, {}) };
+ my $err = $@;
+
+ if (my $expected_error = $test->{expected_error}) {
+ like($err, $expected_error, $test->{description});
+ } elsif ($err) {
+ fail($test->{description});
+ diag("unexpected error: $err");
+ } else {
+ my @missing = grep { !-d "$path/$_" } $test->{expected_dirs}->@*;
+ ok(!scalar(@missing), $test->{description}) || diag("missing: @missing");
+ }
+}
+
+done_testing();
+
+1;
diff --git a/src/test/run_plugin_tests.pl b/src/test/run_plugin_tests.pl
index 5fb0b52..a4dd3da 100755
--- a/src/test/run_plugin_tests.pl
+++ b/src/test/run_plugin_tests.pl
@@ -20,6 +20,7 @@ my $res = $harness->runtests(
"prune_backups_test.pm",
"free_image_test.pm",
"zfs_list_zvol_test.pm",
+ "activate_storage_test.pm",
);
exit -1 if !$res || $res->{failed} || $res->{parse_errors};
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-12 4:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 4:44 [PATCH storage] fix #8212: plugin: allow activating storages with content type 'none' Lucas Barros
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox