all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 4/6] config: apply pending: efi: enroll Microsoft UEFI CA 2023 when setting ms-cert=2023 option
Date: Thu, 11 Dec 2025 13:31:24 +0100	[thread overview]
Message-ID: <20251211123145.143908-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20251211123145.143908-1-f.ebner@proxmox.com>

Like this, the 'qm enroll-efi-keys' operation can be done via API too.

The previous Microsoft UEFI CA 2011 will expire in June 2026, so there
should be a way to update that can be automated and done while guests
are running.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer.pm      |  9 +++++++++
 src/PVE/QemuServer/OVMF.pm | 16 ++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index dfa74c4b..6492d706 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -4988,6 +4988,15 @@ sub vmconfig_apply_pending {
             if (defined($conf->{$opt}) && is_valid_drivename($opt)) {
                 my $old_drive = parse_drive($opt, $conf->{$opt});
                 vmconfig_register_unused_drive($storecfg, $vmid, $conf, $old_drive);
+                if ($opt eq 'efidisk0') {
+                    my $new_drive = parse_drive($opt, $conf->{pending}->{$opt});
+                    PVE::QemuServer::OVMF::drive_change(
+                        $storecfg,
+                        $vmid,
+                        $old_drive,
+                        $new_drive,
+                    );
+                }
             } elsif (defined($conf->{pending}->{$opt}) && $opt =~ m/^net\d+$/) {
                 my $new_net = PVE::QemuServer::Network::parse_net($conf->{pending}->{$opt});
                 if ($conf->{$opt}) {
diff --git a/src/PVE/QemuServer/OVMF.pm b/src/PVE/QemuServer/OVMF.pm
index 4aa98100..58415899 100644
--- a/src/PVE/QemuServer/OVMF.pm
+++ b/src/PVE/QemuServer/OVMF.pm
@@ -317,4 +317,20 @@ sub ensure_ms_2023_cert_enrolled {
     return $efidisk;
 }
 
+sub drive_change {
+    my ($storecfg, $vmid, $old_drive, $new_drive) = @_;
+
+    return if $old_drive->{file} ne $new_drive->{file};
+
+    # Note that changing away from ms-cert=2023 is allowed, the marker is not the source of truth.
+    return if $old_drive->{'ms-cert'} && $old_drive->{'ms-cert'} eq '2023';
+
+    return if !$new_drive->{'ms-cert'} || $new_drive->{'ms-cert'} ne '2023';
+
+    # The ms-cert marker was newly changed to 2023, ensure it's enrolled. Clear it first to avoid
+    # detecting as already enrolled.
+    delete $new_drive->{'ms-cert'};
+    ensure_ms_2023_cert_enrolled($storecfg, $vmid, $new_drive);
+}
+
 1;
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

  parent reply	other threads:[~2025-12-11 12:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-11 12:31 [pve-devel] [PATCH-SERIES qemu-server/manager 0/6] improve Microsoft UEFI CA 2023 enrollment Fiona Ebner
2025-12-11 12:31 ` [pve-devel] [PATCH qemu-server 1/6] qm enroll-efi-keys: do not remove EFI disk when config was modified during operation Fiona Ebner
2025-12-11 12:31 ` [pve-devel] [PATCH qemu-server 2/6] ovmf: enroll ms 2023 cert: pass along parsed drive Fiona Ebner
2025-12-11 12:31 ` [pve-devel] [PATCH qemu-server 3/6] config: apply pending: code style: avoid some line bloat Fiona Ebner
2025-12-11 12:31 ` Fiona Ebner [this message]
2025-12-11 12:31 ` [pve-devel] [PATCH manager 5/6] ui: qemu: hd efi: fix typo in warning Fiona Ebner
2025-12-11 12:31 ` [pve-devel] [PATCH manager 6/6] ui: qemu: hardware: efi: allow enrolling Microsoft UEFI CA 2023 Fiona Ebner
2026-01-07 10:11 ` [pve-devel] [PATCH-SERIES qemu-server/manager 0/6] improve Microsoft UEFI CA 2023 enrollment Fiona Ebner

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=20251211123145.143908-5-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --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