public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ludwig <christian_ludwig@genua.de>
To: <pve-devel@lists.proxmox.com>
Subject: [PATCH pve-storage v4 04/20] plugin: allow overriding the efi-firmware directory
Date: Thu, 19 Nov 2026 15:14:11 +0100	[thread overview]
Message-ID: <a96aae40717f40bc3779f5267fa41eaa12ceb138.1795092172.git.christian_ludwig@genua.de> (raw)
In-Reply-To: <cover.1795092172.git.christian_ludwig@genua.de>

The content type of a directory override must consist of lowercase
letters only, so 'efi-firmware' could not be overridden like the other
types with a directory. Worse, as the override list is invalid as a
whole then, setting it through the API fails and a storage.cfg that
contains it loses all directory overrides of that storage.

Accept content types with hyphens. That would also accept the volume
types of guests, though their volumes all share the directory of their
generic type, so the override would be ignored silently. Reject those.

Signed-off-by: Christian Ludwig <christian_ludwig@genua.de>
---
 src/PVE/Storage/Plugin.pm      |  8 ++++++--
 src/test/content_types_test.pm | 28 +++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index fd4a2cc..20dbdbc 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -487,9 +487,13 @@ PVE::JSONSchema::register_format('pve-dir-override', \&verify_dir_override);
 sub verify_dir_override {
     my ($value, $noerr) = @_;
 
-    if ($value =~ m/^([a-z]+)=([^.]*(?:\.?[^.]+)+)$/) {
+    if ($value =~ m/^([a-z]+(?:-[a-z]+)*)=([^.]*(?:\.?[^.]+)+)$/) {
         my ($content_type, $relative_path) = ($1, $2);
-        if (verify_content($content_type, $noerr)) {
+        # the volumes of all guest volume types share the directory of their generic type
+        if (
+            verify_content($content_type, $noerr)
+            && !defined(PVE::Storage::Common::generic_vtype($content_type))
+        ) {
             # linux has 4k max-path, but limit total length to lower as its concat'd for full path
             if (
                 length($relative_path) < 1023
diff --git a/src/test/content_types_test.pm b/src/test/content_types_test.pm
index 8aa13eb..2a7eec5 100644
--- a/src/test/content_types_test.pm
+++ b/src/test/content_types_test.pm
@@ -115,8 +115,8 @@ lvm: redundant
 
 dir: overrides
 	path /srv/overrides
-	content iso,backup
-	content-dirs iso=images/iso,backup=dumps
+	content iso,backup,efi-firmware
+	content-dirs iso=images/iso,backup=dumps,efi-firmware=firmware
 CFG
 
 my $cfg = PVE::Storage::Plugin->parse_config('storage.cfg', $raw);
@@ -256,7 +256,11 @@ for my $test ($api_tests->@*) {
 }
 
 my $content_dirs = PVE::API2::Storage::Config->read({ storage => 'overrides' })->{'content-dirs'};
-is($content_dirs, 'backup=dumps,iso=images/iso', 'overrides: content directories as read');
+is(
+    $content_dirs,
+    'backup=dumps,efi-firmware=firmware,iso=images/iso',
+    'overrides: content directories as read',
+);
 eval {
     PVE::API2::Storage::Config->update({
         storage => 'overrides',
@@ -265,6 +269,24 @@ eval {
 };
 is($@, '', 'overrides: content directories can be set as read');
 
+# each test is comprised of the following array keys:
+# [0] => directory override
+# [1] => whether it is valid
+my $dir_override_tests = [
+    ['efi-firmware=firmware', 1],
+    ['images=guests', 1],
+    # the volumes of all guest volume types share the directory of their generic type
+    ['vm-vol=disks', 0],
+    ['ct-vol=volumes', 0],
+];
+
+for my $test ($dir_override_tests->@*) {
+    my ($override, $expected) = $test->@*;
+
+    my $valid = defined(PVE::Storage::Plugin::verify_dir_override($override, 1)) ? 1 : 0;
+    is($valid, $expected, "directory override $override");
+}
+
 done_testing();
 
 1;
-- 
2.34.1




  parent reply	other threads:[~2026-11-19 14:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 14:14 [PATCH v4 00/20] Support for custom EFI firmware Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-storage v4 01/20] plugin: add efi-firmware content type Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-storage v4 02/20] test: get_subdir: cover the " Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-storage v4 03/20] plugins: allow the efi-firmware content type on file based storages Christian Ludwig
2026-11-19 14:14 ` Christian Ludwig [this message]
2026-11-19 14:14 ` [PATCH pve-storage v4 05/20] plugin: support efi-firmware volumes in volume export and import Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-storage v4 06/20] api: status: support efi-firmware in upload and download-url Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-storage v4 07/20] test: volume access: cover efi-firmware volumes Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-storage v4 08/20] test: list volumes: " Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-storage v4 09/20] test: cover efi-firmware volumes in parse_volname and path_to_volume_id Christian Ludwig
2026-11-19 14:14 ` [PATCH qemu-server v4 10/20] config: define bios schema as property-string Christian Ludwig
2026-11-19 14:14 ` [PATCH qemu-server v4 11/20] bios: add a custom firmware sub-property Christian Ludwig
2026-11-19 14:14 ` [PATCH qemu-server v4 12/20] api: check the custom firmware of the bios option Christian Ludwig
2026-11-19 14:14 ` [PATCH qemu-server v4 13/20] test: custom firmware in " Christian Ludwig
2026-11-19 14:14 ` [PATCH qemu-server v4 14/20] test: custom firmware volumes in replication and migration Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-manager v4 15/20] ui: storage: add efi-firmware content type support Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-manager v4 16/20] ui: form: support other content types in the ISO selector Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-manager v4 17/20] ui: qemu: allow selecting a custom EFI firmware image Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-manager v4 18/20] ui: migrate: refuse migration with a local custom " Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-docs v4 19/20] pvesm: document the efi-firmware content type Christian Ludwig
2026-11-19 14:14 ` [PATCH pve-docs v4 20/20] qm: document the custom firmware of the bios option Christian Ludwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a96aae40717f40bc3779f5267fa41eaa12ceb138.1795092172.git.christian_ludwig@genua.de \
    --to=christian_ludwig@genua.de \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal