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 v3 01/19] plugin: add efi-firmware content type
Date: Tue, 27 Oct 2026 11:12:06 +0100	[thread overview]
Message-ID: <01c34eb1dde147435381239f92e2a0fcccfcffbe.1793029144.git@genua.de> (raw)
In-Reply-To: <cover.1793029144.git@genua.de>

Holds custom OVMF code images in the efi-firmware/ subdirectory of a
storage. File names are restricted to the safe character class and must
end with '.fd'. Requiring the extension avoids confusion with other
image formats and leaves room for supporting other firmware formats
later on. Access is granted like for ISO images.

Signed-off-by: Christian Ludwig <christian_ludwig@genua.de>
---
 src/PVE/Storage.pm        | 23 +++++++++++++++++++----
 src/PVE/Storage/Plugin.pm | 15 ++++++++++++++-
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index cfbbabd..03ec6a1 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -123,6 +123,8 @@ our $IMPORT_EXT_RE_1 = qr/\.(ova|ovf|qcow2|raw|vmdk)/;
 
 our $UPLOAD_IMPORT_EXT_RE_1 = qr/\.(ova|qcow2|raw|vmdk)/;
 
+our $EFI_FIRMWARE_EXT_RE_1 = qr/\.(fd)/;
+
 our $SAFE_CHAR_CLASS_RE = qr/[a-zA-Z0-9\-\.\+\=\_]/;
 our $SAFE_CHAR_WITH_WHITESPACE_CLASS_RE = qr/[ a-zA-Z0-9\-\.\+\=\_]/;
 
@@ -629,7 +631,12 @@ sub check_volume_access {
 
         return if $rpcenv->check($user, "/storage/$sid", ['Datastore.Allocate'], 1);
 
-        if ($vtype eq 'iso' || $vtype eq 'vztmpl' || $vtype eq 'import') {
+        if (
+            $vtype eq 'iso'
+            || $vtype eq 'vztmpl'
+            || $vtype eq 'import'
+            || $vtype eq 'efi-firmware'
+        ) {
             # require at least read access to storage, (custom) templates/ISOs could be sensitive
             $rpcenv->check_any(
                 $user,
@@ -719,6 +726,7 @@ sub path_to_volume_id {
         my $backupdir = $plugin->get_subdir($scfg, 'backup');
         my $snippetsdir = $plugin->get_subdir($scfg, 'snippets');
         my $importdir = $plugin->get_subdir($scfg, 'import');
+        my $firmwaredir = $plugin->get_subdir($scfg, 'efi-firmware');
 
         if ($path =~ m!^\Q$imagedir\E/(\d+)/([^/\s]+)$!) {
             my $vmid = $1;
@@ -747,6 +755,9 @@ sub path_to_volume_id {
         } elsif ($path =~ m!^\Q$importdir\E/(${SAFE_CHAR_CLASS_RE}+${IMPORT_EXT_RE_1})$!) {
             my $name = $1;
             return ('import', "$sid:import/$name");
+        } elsif ($path =~ m!^\Q$firmwaredir\E/(${SAFE_CHAR_CLASS_RE}+${EFI_FIRMWARE_EXT_RE_1})$!) {
+            my $name = $1;
+            return ('efi-firmware', "$sid:efi-firmware/$name");
         }
     }
 
@@ -1269,7 +1280,11 @@ sub template_list {
     my ($cfg, $storeid, $tt) = @_;
 
     die "unknown template type '$tt'\n"
-        if !($tt eq 'iso' || $tt eq 'vztmpl' || $tt eq 'backup' || $tt eq 'snippets');
+        if !($tt eq 'iso'
+            || $tt eq 'vztmpl'
+            || $tt eq 'backup'
+            || $tt eq 'snippets'
+            || $tt eq 'efi-firmware');
 
     my $ids = $cfg->{ids};
 
@@ -1297,7 +1312,7 @@ sub template_list {
 sub volume_list {
     my ($cfg, $storeid, $vmid, $content) = @_;
 
-    my @ctypes = qw(rootdir images vztmpl iso backup snippets import);
+    my @ctypes = qw(rootdir images vztmpl iso backup snippets import efi-firmware);
 
     my $cts = $content ? [$content] : [@ctypes];
 
@@ -2264,7 +2279,7 @@ sub complete_storage_enabled {
 sub complete_content_type {
     my ($cmdname, $pname, $cvalue) = @_;
 
-    return [qw(rootdir images vztmpl iso backup snippets import)];
+    return [qw(rootdir images vztmpl iso backup snippets import efi-firmware)];
 }
 
 sub complete_volume {
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 8318a68..43af559 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -384,7 +384,7 @@ PVE::JSONSchema::register_format('pve-storage-content', \&verify_content);
 sub verify_content {
     my ($ct, $noerr) = @_;
 
-    return $ct if $ct eq 'import';
+    return $ct if $ct eq 'import' || $ct eq 'efi-firmware';
 
     my $valid_content = valid_content_types('dir'); # dir includes all other types
 
@@ -843,6 +843,10 @@ sub parse_volname {
         m!^import/(${PVE::Storage::SAFE_CHAR_WITH_WHITESPACE_CLASS_RE}+$PVE::Storage::IMPORT_EXT_RE_1)$!
     ) {
         return ('import', $1, undef, undef, undef, undef, $2);
+    } elsif ($volname =~
+        m!^efi-firmware/(${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::EFI_FIRMWARE_EXT_RE_1)$!
+    ) {
+        return ('efi-firmware', $1, undef, undef, undef, undef, 'raw');
     }
 
     die "unable to parse directory volume name '$volname'\n";
@@ -948,6 +952,7 @@ my $vtype_subdirs = {
     backup => 'dump',
     snippets => 'snippets',
     import => 'import',
+    'efi-firmware' => 'efi-firmware',
 };
 
 sub get_vtype_subdirs {
@@ -1855,6 +1860,12 @@ my $get_subdir_files = sub {
                 m!/(${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::IMPORT_EXT_RE_1)$!i;
 
             $info = { volid => "$sid:import/$1", format => "$2" };
+        } elsif ($tt eq 'efi-firmware') {
+            next
+                if $fn !~
+                m!/(${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::EFI_FIRMWARE_EXT_RE_1)$!;
+
+            $info = { volid => "$sid:efi-firmware/$1", format => 'raw' };
         }
 
         $info->{size} = $st->size;
@@ -1891,6 +1902,8 @@ sub list_volumes {
                 $data = $get_subdir_files->($storeid, $path, 'snippets');
             } elsif ($type eq 'import') {
                 $data = $get_subdir_files->($storeid, $path, 'import');
+            } elsif ($type eq 'efi-firmware' && !defined($vmid)) {
+                $data = $get_subdir_files->($storeid, $path, 'efi-firmware');
             }
         }
 
-- 
2.34.1




  reply	other threads:[~2026-10-27 10:12 UTC|newest]

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