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 1/4] ovmf: enroll ms 2023 cert: change QSD ID to allow calling outside of VM start
Date: Tue, 18 Nov 2025 13:34:39 +0100	[thread overview]
Message-ID: <20251118123516.112546-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20251118123516.112546-1-f.ebner@proxmox.com>

The main QSD instance with ID $vmid can only be re-used as part of
VM start tasks. In preparation to allow calling the method from a new
enroll-efi-keys command/endpoint, change the QSD ID to something else.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer/OVMF.pm | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/PVE/QemuServer/OVMF.pm b/src/PVE/QemuServer/OVMF.pm
index 408144a0..409ad022 100644
--- a/src/PVE/QemuServer/OVMF.pm
+++ b/src/PVE/QemuServer/OVMF.pm
@@ -278,8 +278,6 @@ sub print_ovmf_commandline {
     return ($cmd, $machine_flags);
 }
 
-# May only be called as part of VM start right now, because it uses the main QSD associated to the
-# VM. If required for another scenario, change the QSD ID to something else.
 sub ensure_ms_2023_cert_enrolled {
     my ($storecfg, $vmid, $efidisk_str) = @_;
 
@@ -289,19 +287,22 @@ sub ensure_ms_2023_cert_enrolled {
 
     print "efidisk0: enrolling Microsoft UEFI CA 2023\n";
 
-    my $new_qsd = !PVE::QemuServer::Helpers::qsd_running_locally($vmid);
-    PVE::QemuServer::QSD::start($vmid) if $new_qsd;
+    my $qsd_id = "vm-$vmid-efi-enroll";
+    if (my $qsd_pid = PVE::QemuServer::Helpers::qsd_running_locally($qsd_id)) {
+        die "QEMU storage daemon $qsd_id already running with PID $qsd_pid (left over process?)\n";
+    }
+    PVE::QemuServer::QSD::start($qsd_id);
 
     eval {
         my $efi_vars_path =
-            PVE::QemuServer::QSD::add_fuse_export($vmid, $efidisk, 'efidisk0-enroll');
+            PVE::QemuServer::QSD::add_fuse_export($qsd_id, $efidisk, 'efidisk0-enroll');
         PVE::Tools::run_command(
             ['virt-fw-vars', '--inplace', $efi_vars_path, '--distro-keys', 'ms-uefi']);
-        PVE::QemuServer::QSD::remove_fuse_export($vmid, 'efidisk0-enroll');
+        PVE::QemuServer::QSD::remove_fuse_export($qsd_id, 'efidisk0-enroll');
     };
     my $err = $@;
 
-    PVE::QemuServer::QSD::quit($vmid) if $new_qsd;
+    PVE::QemuServer::QSD::quit($qsd_id);
 
     die "efidisk0: enrolling Microsoft UEFI CA 2023 failed - $err" if $err;
 
-- 
2.47.3



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


  reply	other threads:[~2025-11-18 12:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18 12:34 [pve-devel] [PATCH-SERIS qemu-server 0/4] vm start: ovmf: do not auto-enroll Microsoft UEFI CA 2023 Fiona Ebner
2025-11-18 12:34 ` Fiona Ebner [this message]
2025-11-18 12:34 ` [pve-devel] [PATCH qemu-server 2/4] api/cli: add enroll-efi-keys endpoint Fiona Ebner
2025-11-18 12:58   ` Fabian Grünbichler
2025-11-18 13:07     ` Thomas Lamprecht
2025-11-18 13:09       ` Fabian Grünbichler
2025-11-18 14:11         ` Thomas Lamprecht
2025-11-18 12:34 ` [pve-devel] [PATCH qemu-server 3/4] ovmf: factor out helper for checking whether MS 2023 certificate should be enrolled Fiona Ebner
2025-11-18 12:34 ` [pve-devel] [PATCH qemu-server 4/4] vm start: ovmf: do not auto-enroll Microsoft UEFI CA 2023 Fiona Ebner
2025-11-18 13:30 ` [pve-devel] [PATCH-SERIS qemu-server 0/4] " Thomas Lamprecht

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=20251118123516.112546-2-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