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 CD1DA1FF0DE for ; Thu, 19 Nov 2026 15:15:30 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 216702181E; Thu, 19 Nov 2026 15:14:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=genua.de; s=202307; t=1795097647; bh=X2il38qLJbhuTAOjid2yNhfW/BGee9bmELsLC7xa2XQ=; h=Date:From:To:Subject:References:In-Reply-To:From; b=quOjEZxmXwL4xVu9t80ZHABrbPVXQbys/i6SXLCgf4nJe3bjcmzMYkqMfe0+s8jVJ PW3M9F1wp8Dvo8HaBOCJxmYe0JrvIzPo5PcpcUKcArelBF81/JvmA8UtwXpHzb+72J 74lPs7+KVc3+uTCMIPZU4Cofc3d/0TjbFdQqBPZkABr7cGv8Iy9MYQCDwJejn8AXRq NRckk+wC+qpLOik0ra7+12nqai2Yy7ygKJfIn+PoHIpjzE4yKUbpuPLvz7tR/IwLSo 6U2Fvz9VESd9rKHpOCT3KkGHTCpY112W+fOtaVadF61LKSkr4OqEz6eM74JhH1LJeG Rq8x6CVDGQCMQ== Date: Thu, 19 Nov 2026 15:14:06 +0100 From: Christian Ludwig To: Subject: [PATCH pve-storage v4 01/20] plugin: add efi-firmware content type Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [192.168.217.185] X-ClientProxiedBy: kch1-mta08.win.genua.de (10.208.16.108) To kch1-mta07.win.genua.de (10.208.16.107) Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-SPAM-LEVEL: Spam detection results: 0 AWL 0.056 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 RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_PASS -0.001 SPF: sender matches SPF record UNPARSEABLE_RELAY 0.001 Informational: message has unparseable relay lines Message-ID-Hash: JXJHOITTSBKCSYXFFD2RE7ASQRRWZ4M6 X-Message-ID-Hash: JXJHOITTSBKCSYXFFD2RE7ASQRRWZ4M6 X-MailFrom: christian_ludwig@genua.de 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: 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. Reviewed-by: Fiona Ebner Signed-off-by: Christian Ludwig --- src/PVE/Storage.pm | 25 +++++++++++++++++++++---- src/PVE/Storage/Plugin.pm | 17 +++++++++++++++-- src/test/parse_volname_test.pm | 8 ++++++++ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index faf325f..8c79c13 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -188,6 +188,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\-\.\+\=\_]/; @@ -698,7 +700,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, @@ -797,6 +804,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; @@ -826,6 +834,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"); } } @@ -1357,7 +1368,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}; @@ -1385,7 +1400,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); # plugins list the volumes of guests by their generic content type my $vtype; @@ -2390,7 +2405,9 @@ sub complete_storage_enabled { sub complete_content_type { my ($cmdname, $pname, $cvalue) = @_; - return [qw(rootdir ct-vol images vm-vol vm-state vztmpl iso backup snippets import)]; + return [ + qw(rootdir ct-vol images vm-vol vm-state 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 724c2d3..fd4a2cc 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -427,7 +427,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 @@ -922,6 +922,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"; @@ -1028,6 +1032,7 @@ my $vtype_subdirs = { backup => 'dump', snippets => 'snippets', import => 'import', + 'efi-firmware' => 'efi-firmware', }; sub get_vtype_subdirs { @@ -1874,7 +1879,7 @@ sub list_images { return $res; } -# list templates ($tt = ) +# list templates ($tt = ) my $get_subdir_files = sub { my ($sid, $path, $tt, $vmid) = @_; @@ -1940,6 +1945,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; @@ -1976,6 +1987,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'); } } diff --git a/src/test/parse_volname_test.pm b/src/test/parse_volname_test.pm index 5eb7f55..b8a4a21 100644 --- a/src/test/parse_volname_test.pm +++ b/src/test/parse_volname_test.pm @@ -203,6 +203,14 @@ my $tests = [ expected => ['import', 'import.ova/disk.raw', undef, undef, undef, undef, 'ova+raw'], }, # + # EFI firmware + # + { + description => 'EFI firmware, fd', + volname => 'efi-firmware/custom-ovmf-code.fd', + expected => ['efi-firmware', 'custom-ovmf-code.fd', undef, undef, undef, undef, 'raw'], + }, + # # failed matches # { -- 2.34.1