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 9F2E01FF0DE for ; Thu, 19 Nov 2026 15:16:19 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2CBC52178E; Thu, 19 Nov 2026 15:15:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=genua.de; s=202307; t=1795097664; bh=ufipAJiN6laF34K5Lm48q6sQ/74VmiBWT3o2FC6P50s=; h=Date:From:To:Subject:References:In-Reply-To:From; b=JrTYImD5fKilkvlnExBTwZxyrE2cjyFlkCzFR99yQD4kIbqb1WwKpzc5kGBspzmfd a5zO8GucY1EZRg9itHex5NzkLqa0+0zYDx7OT4rYYFcAKWCSK5elg3zp1QdsaZm5tD vyoWXTfi/EsnIJDMoLRNgPzoORI7hXraqYdJEwdC63WtQmjuLm0VPYtCh8GxOM8q5J KMirkm1z5gJVdqQiFa3qFxIrdNqCLnBo3nBdyQsORbwl4B1TdwVEPTzzEf6esXVVBI qHDfGU28JzjGgzdqbVOyc+OdsrtBGevNLgjYLNOF9KlDc1dZYn8frpo1U+DWCzLJiG wgWvqgYIZlPBQ== Date: Thu, 19 Nov 2026 15:14:23 +0100 From: Christian Ludwig To: Subject: [PATCH qemu-server v4 12/20] api: check the custom firmware of the bios option Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [192.168.217.185] X-ClientProxiedBy: kch1-mta09.win.genua.de (10.208.16.109) 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.053 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: 4MFCP4X5QQX6CEEELSUBOIBXLCHBHY6A X-Message-ID-Hash: 4MFCP4X5QQX6CEEELSUBOIBXLCHBHY6A 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: When the bios option is set via the POST/PUT {vmid}/config endpoints, check that the user may access the custom firmware image, that it is an efi-firmware volume, and that the BIOS type is 'ovmf'. Like for ISO images, whether the image is usable on the node is only checked when the VM is started. The option keeps requiring the VM.Config.Options permission. A cloned VM references the same firmware image, like an ISO image, so a clone is only considered shared if the image is on a shared storage. Report custom firmware images in the local disks of the migration precondition check, so that clients can tell why a migration is not possible. Signed-off-by: Christian Ludwig --- src/PVE/API2/Qemu.pm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index e0661738..943d606f 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -33,6 +33,7 @@ use PVE::GuestImport; use PVE::QemuConfig; use PVE::QemuServer; use PVE::QemuServer::Agent; +use PVE::QemuServer::BIOS; use PVE::QemuServer::Blockdev; use PVE::QemuServer::BlockJob; use PVE::QemuServer::Cloudinit; @@ -198,6 +199,18 @@ my $foreach_volume_with_alloc = sub { } }; +my sub check_bios_param { + my ($param) = @_; + + return if !defined($param->{bios}); + + eval { PVE::QemuServer::BIOS::check_bios($param->{bios}) }; + if (my $err = $@) { + chomp($err); + raise_param_exc({ bios => $err }); + } +} + my $check_drive_param = sub { my ($param, $storecfg, $extra_checks) = @_; @@ -383,6 +396,13 @@ my $check_storage_access = sub { ); } } + + my $firmware = PVE::QemuServer::BIOS::parse_bios($settings->{bios})->{firmware}; + if (defined($firmware)) { + PVE::Storage::check_volume_access( + $rpcenv, $authuser, $storecfg, $vmid, $firmware, 'efi-firmware', + ); + } }; my $check_storage_access_clone = sub { @@ -425,6 +445,13 @@ my $check_storage_access_clone = sub { $rpcenv->check($authuser, "/storage/$conf->{vmstatestorage}", ['Datastore.AllocateSpace']) if defined($conf->{vmstatestorage}); + # like ISO images, a custom firmware image is simply referenced by the clone + if (my $firmware = PVE::QemuServer::BIOS::get_bios_firmware($conf)) { + my ($sid) = PVE::Storage::parse_volume_id($firmware); + my $scfg = PVE::Storage::storage_config($storecfg, $sid); + $sharedvm = 0 if !$scfg->{shared}; + } + return $sharedvm; }; @@ -1499,6 +1526,7 @@ __PACKAGE__->register_method({ &$check_cpu_model_access($rpcenv, $authuser, $param); $check_drive_param->($param, $storecfg); + check_bios_param($param); PVE::QemuServer::Network::add_random_macs($param); } @@ -2339,6 +2367,8 @@ my $update_vm_api = sub { $rpcenv, $authuser, $storecfg, $vmid, $param, undef, $extraction_storage, ); + check_bios_param($param); + PVE::QemuServer::check_bridge_access($rpcenv, $authuser, $param); my $load_and_check_config = sub { @@ -5551,6 +5581,11 @@ __PACKAGE__->register_method({ type => 'boolean', description => 'True if the disk is a cdrom.', }, + is_firmware => { + type => 'boolean', + description => 'True if the volume is a custom firmware image.', + optional => 1, + }, is_unused => { type => 'boolean', description => 'True if the disk is unused.', -- 2.34.1