From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 086EF1FF0B6 for ; Thu, 12 Nov 2026 05:44:46 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 198E82166F; Thu, 12 Nov 2026 05:44:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794458670; x=1795063470; darn=lists.proxmox.com; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=liqaI6Sbp75LQpFTRlyRfTJNtY7m0G92JCSjv5IM1PA=; b=KhojUa2QYuJdAodOTWAC354EqxFwIc8bgBiMB9O/+xPq81oSW+6dGw3kq889iZYI20 D8gE2ReGMep39vt1xyQM4DpGLRmQiWesoAEUU1duCAxJ7soX7s06zl1Z5iL+eWp+Ti5Y KDDY8jP3w5Qxbkdig6MSw4yC35/22BY5xzp1NH5F8dDH76YRVj8EfKc1/WAQsppR7Iz2 j11yC7tAoNzd69SZgWKWo5dhdiaUGutjuoMdkuIAwC8ayRkEdMbueE6/6ThSJBwP64yn Mjs7fHdMVOH93eYhN3mS/UzCz4EQqihKNQIpDJvyuF3+Gq35pEY+/RQZ0tdw2hCuBc7p ur4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794458670; x=1795063470; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=liqaI6Sbp75LQpFTRlyRfTJNtY7m0G92JCSjv5IM1PA=; b=dT+kDwb9zlZSJU1QDyIRHa1Ttf/c9hdjpvg5g7e6U3AzQONLb8bHWV6uo0gr+kHnZb /FNB84Z6bi4vlmkyifEgRmAVq4M2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G7vcRRJ834rGO6DBza+N6 X-Received: by 2002:a05:690c:fd1:b0:8b3:2a74:e0de with SMTP id 00721157ae682-8b3a7e003eemr27859497b3.14.1794458669862; Wed, 11 Nov 2026 20:44:29 -0800 (PST) From: Lucas Barros To: pve-devel@lists.proxmox.com Subject: [PATCH storage] fix #8212: plugin: allow activating storages with content type 'none' Date: Thu, 12 Nov 2026 01:44:24 -0300 Message-ID: <20261112044424.82483-1-lucasbarros.kam@gmail.com> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.050 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no 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: UMU5OFBXKLK2X73NYNWVRM5P3HGRLEGB X-Message-ID-Hash: UMU5OFBXKLK2X73NYNWVRM5P3HGRLEGB X-MailFrom: lucasbarros.kam@gmail.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: 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 --- 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)