all lists on 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 06/20] api: status: support efi-firmware in upload and download-url
Date: Thu, 19 Nov 2026 15:14:14 +0100	[thread overview]
Message-ID: <558bfdffe1424c14c45e5a6fad96f7b7391ace03.1795092172.git.christian_ludwig@genua.de> (raw)
In-Reply-To: <cover.1795092172.git.christian_ludwig@genua.de>

Allow the content type in both endpoints. File names must consist of the
safe character class and end with '.fd'. Validate the image after the
transfer, like for other content types, and reject anything that is not
detected as a raw image.

The format check has no timeout, like the ISO content check, whose
qemu-img call (auto-detected format, untrusted) it mirrors. A timeout
would only limit qemu-img info on the already transferred temporary file,
not the upload or download itself.

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Christian Ludwig <christian_ludwig@genua.de>
---
 src/PVE/API2/Storage/Status.pm | 22 ++++++++++++++++++++--
 src/PVE/Storage.pm             | 19 +++++++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm
index 57ab92b..0039d81 100644
--- a/src/PVE/API2/Storage/Status.pm
+++ b/src/PVE/API2/Storage/Status.pm
@@ -534,7 +534,7 @@ __PACKAGE__->register_method({
                 description => "Content type.",
                 type => 'string',
                 format => 'pve-storage-content',
-                enum => ['iso', 'vztmpl', 'import'],
+                enum => ['iso', 'vztmpl', 'import', 'efi-firmware'],
             },
             filename => {
                 description =>
@@ -619,6 +619,13 @@ __PACKAGE__->register_method({
             }
 
             $path = PVE::Storage::get_import_dir($cfg, $storage);
+        } elsif ($content eq 'efi-firmware') {
+            if ($filename !~
+                m!^${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::EFI_FIRMWARE_EXT_RE_1$!
+            ) {
+                raise_param_exc({ filename => "invalid filename or wrong extension" });
+            }
+            $path = PVE::Storage::get_efi_firmware_dir($cfg, $storage);
         } else {
             raise_param_exc({ content => "upload content type '$content' not allowed" });
         }
@@ -690,6 +697,8 @@ __PACKAGE__->register_method({
 
                 if ($content eq 'iso') {
                     PVE::Storage::assert_iso_content($tmpfilename);
+                } elsif ($content eq 'efi-firmware') {
+                    PVE::Storage::assert_efi_firmware_content($tmpfilename);
                 }
 
                 if ($is_ova) {
@@ -767,7 +776,7 @@ __PACKAGE__->register_method({
                 description => "Content type.", # TODO: could be optional & detected in most cases
                 type => 'string',
                 format => 'pve-storage-content',
-                enum => ['iso', 'vztmpl', 'import'],
+                enum => ['iso', 'vztmpl', 'import', 'efi-firmware'],
             },
             filename => {
                 description =>
@@ -856,6 +865,13 @@ __PACKAGE__->register_method({
             }
 
             $path = PVE::Storage::get_import_dir($cfg, $storage);
+        } elsif ($content eq 'efi-firmware') {
+            if ($filename !~
+                m!^${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::EFI_FIRMWARE_EXT_RE_1$!
+            ) {
+                raise_param_exc({ filename => "invalid filename or wrong extension" });
+            }
+            $path = PVE::Storage::get_efi_firmware_dir($cfg, $storage);
         } else {
             raise_param_exc({ content => "upload content-type '$content' is not allowed" });
         }
@@ -882,6 +898,8 @@ __PACKAGE__->register_method({
 
             if ($content eq 'iso') {
                 PVE::Storage::assert_iso_content($tmp_path);
+            } elsif ($content eq 'efi-firmware') {
+                PVE::Storage::assert_efi_firmware_content($tmp_path);
             }
 
             if ($is_ova) {
diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index 8c79c13..d02141d 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -622,6 +622,15 @@ sub get_iso_dir {
     return $plugin->get_subdir($scfg, 'iso');
 }
 
+sub get_efi_firmware_dir {
+    my ($cfg, $storeid) = @_;
+
+    my $scfg = storage_config($cfg, $storeid);
+    my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+
+    return $plugin->get_subdir($scfg, 'efi-firmware');
+}
+
 sub get_import_dir {
     my ($cfg, $storeid) = @_;
 
@@ -2642,4 +2651,14 @@ sub assert_iso_content {
     return 1;
 }
 
+sub assert_efi_firmware_content {
+    my ($path) = @_;
+
+    my (undef, $format) = file_size_info($path, undef, 'auto-detect', 1);
+    die "efi-firmware image format could not be detected\n" if !defined($format);
+    die "efi-firmware image is not in raw format, detected '$format'\n" if $format ne 'raw';
+
+    return 1;
+}
+
 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 ` [PATCH pve-storage v4 04/20] plugin: allow overriding the efi-firmware directory Christian Ludwig
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 ` Christian Ludwig [this message]
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=558bfdffe1424c14c45e5a6fad96f7b7391ace03.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal