Message ID | b4dd8d72d2feadb91dcd393e9f9a48b42e30f79c.1742388313.git.maxim.cournoyer@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E779F27BBE9; Wed, 19 Mar 2025 12:47:19 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C1BC127BBE2 for <patchwork@mira.cbaines.net>; Wed, 19 Mar 2025 12:47:18 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1tuspC-0007v3-16; Wed, 19 Mar 2025 08:47:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tusp6-0007uO-6q for guix-patches@gnu.org; Wed, 19 Mar 2025 08:47:05 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tusp5-0003ko-Ue for guix-patches@gnu.org; Wed, 19 Mar 2025 08:47:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=FSW+uewhzV8F/N6LVjsTu2pfCmQGn3c2Gw+W1+NmTgg=; b=JiDICj4bsumCwbX9vhFf2J8RLeZGOCumzLPzGqcWyOWJHvID7E6G6ukMDWrYNNLYrNCM8CwwiCOM4xpVNUKS7JdMjDW+CyqsiZh7s60XqTFUr+t9lR9fE8c5zq84Qc1drHsdcRFumVy6ndjrnnR7yNUzYAq21epzMzeZ7FJDzIn1qeRPGc83+nFT5eFnkoVxBjJFi7LeEYXHMmjZ2ZCnnNo1r17AaDzofgildWhENpj36Yy1ya13ebn9vjpyDq9zF1+MQc6xLQD9seLEyj5cK/jzKQRjSYJKzCrHQy8S7mKefUzBWkD4c28YnuA9rNc/wd8VFVO/oFAH7QUUOxbfQw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tusp4-0003MF-By; Wed, 19 Mar 2025 08:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77110] [PATCH 1/2] gnu: ovmf-x86-64: Install QEMU firmware metadata file. References: <cover.1742368386.git.maxim.cournoyer@gmail.com> In-Reply-To: <cover.1742368386.git.maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer <maxim.cournoyer@gmail.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: efraim@flashner.co.il, vagrant@debian.org, guix-patches@gnu.org Resent-Date: Wed, 19 Mar 2025 12:47:02 +0000 Resent-Message-ID: <handler.77110.B77110.174238836412817@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77110 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77110@debbugs.gnu.org Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>, Efraim Flashner <efraim@flashner.co.il>, Vagrant Cascadian <vagrant@debian.org> X-Debbugs-Original-Xcc: Efraim Flashner <efraim@flashner.co.il>, Vagrant Cascadian <vagrant@debian.org> Received: via spool by 77110-submit@debbugs.gnu.org id=B77110.174238836412817 (code B ref 77110); Wed, 19 Mar 2025 12:47:02 +0000 Received: (at 77110) by debbugs.gnu.org; 19 Mar 2025 12:46:04 +0000 Received: from localhost ([127.0.0.1]:49345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1tuso7-0003Ke-JJ for submit@debbugs.gnu.org; Wed, 19 Mar 2025 08:46:04 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:59757) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <maxim.cournoyer@gmail.com>) id 1tuso5-0003K4-23 for 77110@debbugs.gnu.org; Wed, 19 Mar 2025 08:46:01 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-22548a28d0cso31359105ad.3 for <77110@debbugs.gnu.org>; Wed, 19 Mar 2025 05:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742388354; x=1742993154; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FSW+uewhzV8F/N6LVjsTu2pfCmQGn3c2Gw+W1+NmTgg=; b=FEp/saNqgtvNZq3KO9PWJ8ltWjptyB0sZ+sjNeMEknKFYMsN5iHs1EolXUpKtqwF6u zxOzq2kZB9ANeXTPrG9N2Ew20T4QkRhO9JfsxYAFuprpNFO5f4NFxHUbY5/QwbtG96xd Asq4T6cBIYSUhI097hrz3BCtp0qBUxhxZME/s5imYQnDU9bMTY5Oo2SJqSef+pbl5xM3 KdRBgN2L4MqxY64kT/PLEHBFDbVolPl9lCDprflKEeBD1aH5clGKyQL0ZJj18OWpqyNk 7G8tvs0uny+djIr7QjGzqJXtEHNQRKAtdPrkYlp2LMg+xrh4/8cttI2E+2Bg9fbmRiH5 dzcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742388354; x=1742993154; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FSW+uewhzV8F/N6LVjsTu2pfCmQGn3c2Gw+W1+NmTgg=; b=kEmBER74DMvz7v0gQ8DmOxHzDHc1jZe+1QRFKWeuoq87Sne9UOi+GN2Sfpu+cPvs9f nj2ANG1csOpjGmoPLMSzPR4N8YUloXt4t+Pm+WHs4+OJp5P6ETJh1zxfyijNOj/jTsKo ZruwZnE/Mx8+UgNZV26RnG09o9Wg/m8Jii3wvbnPwqP62MW35EMc/8qJM7czQZ4E7sYa jysItbeO37Ls/N0DRb3ov91eMH8BbYQlIj8Go8VB23ySOTM31NiqSlHtmrjMH9D40Wfl l38Stl1M0fkl5l1IrL5iO79unq+ZiurdWkFrDf+Dfy6CjgpX/ejmSQiKMcteMJSnqxrf LDmA== X-Gm-Message-State: AOJu0YyzWjxWNpIKQrihGvFV3bzFoUZ5fV/9tI9LaVWz/KqLanO/mIAo 4fj+KTOTf5f+dHvila2jIyr12Ixzc9kVVDNZV6HriaUDgxfuDw4XlnZlMA43 X-Gm-Gg: ASbGncuTztevvc4HS0M9KEuLRPMOytklotQdDqw7DQ2P3VfDu+Xdqr2Twjoyh9m5a// VRwUDGLVU7CuGzaXYhCc4dJpFVCYxGQ/8gBy3a8ecpk2abVnsZuVQgqN/y1Nq21WfStixlhYUnu +bAMJHYzuo3ZUDd0AV7XRsO1NFZZSYF1qA7VTaoTAflGwMsyF5LDtxVYUIXNM1CJOnw3V8hfuFJ 8+09oWCSEz+bjMQ1JvuVHsJyNEb4OCeB60eeai3twuOII4vB2MNRxAI6+DvT/FRGFd4YdCb1mYy DlOoXaNP0GoB/I+mGjwL3ZqSo7rejF4nILLPmodcz1/G3MjTxhGNGzthAEILQWd3 X-Google-Smtp-Source: AGHT+IEy90Qk1Q/0J3eNlffqvT7X5XHjhaKNNAJWFOoSszVYGUAyFXBVSft/2o7EiUdTXUsESGReaw== X-Received: by 2002:a05:6a00:3a03:b0:736:5b85:a911 with SMTP id d2e1a72fcca58-7376d61034bmr4121670b3a.8.1742388354333; Wed, 19 Mar 2025 05:45:54 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73711578a5csm11472600b3a.74.2025.03.19.05.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Mar 2025 05:45:53 -0700 (PDT) From: Maxim Cournoyer <maxim.cournoyer@gmail.com> Date: Wed, 19 Mar 2025 21:45:12 +0900 Message-ID: <b4dd8d72d2feadb91dcd393e9f9a48b42e30f79c.1742388313.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
Add UEFI firmware support in libvirt.
|
|
Commit Message
Maxim Cournoyer
March 19, 2025, 12:45 p.m. UTC
* gnu/packages/firmware.scm (ovmf-x86-64) [phases] {install-qemu-firmware-metadata}: New phase. (ovmf-aux-file): New procedure. * gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json: New file. * Makefile.am (AUX_FILES): Register it. Change-Id: I301eac8b79aed523f3b4cdedb7b3925d8fd0ad3d --- Makefile.am | 1 + .../ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json | 36 +++++++++++++++++++ gnu/packages/firmware.scm | 24 ++++++++++++- 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json base-commit: fa39695bbc0c5f79838cbca55d55eebd821a8efa
Comments
51-edk2-ovmf-2m-raw-x64-nosb.json is very similar to a file shipped by qemu, in the sources in pc-bios/descriptors¹. On Wed, Mar 19, 2025 at 09:45:12PM +0900, Maxim Cournoyer wrote: > * gnu/packages/firmware.scm (ovmf-x86-64) > [phases] {install-qemu-firmware-metadata}: New phase. > (ovmf-aux-file): New procedure. > * gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json: New file. > * Makefile.am (AUX_FILES): Register it. > > Change-Id: I301eac8b79aed523f3b4cdedb7b3925d8fd0ad3d > --- > > Makefile.am | 1 + > .../ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json | 36 +++++++++++++++++++ > gnu/packages/firmware.scm | 24 ++++++++++++- > 3 files changed, 60 insertions(+), 1 deletion(-) > create mode 100644 gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json > > diff --git a/Makefile.am b/Makefile.am > index c668b96a37..f2f4a9643e 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -472,6 +472,7 @@ AUX_FILES = \ > gnu/packages/aux-files/linux-libre/5.4-arm64.conf \ > gnu/packages/aux-files/linux-libre/5.4-i686.conf \ > gnu/packages/aux-files/linux-libre/5.4-x86_64.conf \ > + gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json \ > gnu/packages/aux-files/pack-audit.c \ > gnu/packages/aux-files/python/sanity-check.py \ > gnu/packages/aux-files/python/sitecustomize.py \ > diff --git a/gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json b/gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json > new file mode 100644 > index 0000000000..050853e2b8 > --- /dev/null > +++ b/gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json > @@ -0,0 +1,36 @@ > +{ > + "description": "OVMF without SB+SMM, empty varstore", > + "interface-types": [ > + "uefi" > + ], > + "mapping": { > + "device": "flash", > + "mode" : "split", > + "executable": { > + "filename": "/usr/share/edk2/ovmf/OVMF_CODE.fd", > + "format": "raw" > + }, > + "nvram-template": { > + "filename": "/usr/share/edk2/ovmf/OVMF_VARS.fd", > + "format": "raw" > + } > + }, > + "targets": [ > + { > + "architecture": "x86_64", > + "machines": [ > + "pc-i440fx-*", > + "pc-q35-*" > + ] > + } > + ], > + "features": [ > + "acpi-s3", > + "amd-sev", > + "amd-sev-es", > + "verbose-dynamic" > + ], > + "tags": [ > + > + ] > +} > diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm > index 63f767f72b..c1d8ba3719 100644 > --- a/gnu/packages/firmware.scm > +++ b/gnu/packages/firmware.scm > @@ -1001,6 +1001,10 @@ (define* (make-ovmf-firmware arch) > (license (list license:expat > license:bsd-2 license:bsd-3 license:bsd-4))))) > > +(define (ovmf-aux-file name) > + "Return as a gexp the auxiliary OVMF file corresponding to NAME." > + (local-file (search-auxiliary-file (string-append "ovmf/" name)))) > + > (define-public ovmf-x86-64 > (let ((base (make-ovmf-firmware "x86_64"))) > (package > @@ -1022,7 +1026,25 @@ (define-public ovmf-x86-64 > (string-append fmw "/" (string-downcase file) "_x64.bin"))) > (list "OVMF" > "OVMF_CODE" > - "OVMF_VARS")))))))))))) > + "OVMF_VARS"))))) These 3 files we rename from OVMF* to ovmf*_x64.bin, but based on roms/edk2-build.config from the qemu sources² OVMF_CODE would become edk2-x86_64-code.fd. I think we should standardize on using Qemu's naming scheme for the files. Also we currently install these files to %output/share/firmware and there are other files we install to %output/share/qemu and we should probably standardize between them. > + (add-after 'install 'install-qemu-firmware-metadata > + (lambda _ > + ;; The QEMU firmware metadata files are taken from the > + ;; Fedora project (see: > + ;; https://src.fedoraproject.org/rpms/edk2/tree/rawhide). > + (let ((51-edk2-ovmf-2m-raw-x64-nosb.json-source > + #$(ovmf-aux-file "51-edk2-ovmf-2m-raw-x64-nosb.json")) > + (51-edk2-ovmf-2m-raw-x64-nosb.json-dest > + (string-append #$output "/share/qemu/firmware/" > + "51-edk2-ovmf-2m-raw-x64-nosb.json"))) > + (mkdir-p (dirname 51-edk2-ovmf-2m-raw-x64-nosb.json-dest)) > + (copy-file 51-edk2-ovmf-2m-raw-x64-nosb.json-source > + 51-edk2-ovmf-2m-raw-x64-nosb.json-dest) > + (substitute* 51-edk2-ovmf-2m-raw-x64-nosb.json-dest > + (("/usr/share/edk2/ovmf/OVMF_(CODE|VARS).fd" _ kind) > + (string-append > + #$output "/share/firmware/ovmf_" > + (string-downcase kind) "_x64.bin"))))))))))))) Would it be possible to instead use the search-path to find the firmwares or is that not really possible? > > (define-public ovmf-i686 > (let ((base (make-ovmf-firmware "i686"))) > > base-commit: fa39695bbc0c5f79838cbca55d55eebd821a8efa > -- > 2.48.1 > ¹ https://gitlab.com/qemu-project/qemu/-/blob/v9.1.3/pc-bios/descriptors/60-edk2-x86_64.json ² https://gitlab.com/qemu-project/qemu/-/blob/v9.1.3/roms/edk2-build.config#L62
Hi Efraim, Efraim Flashner <efraim@flashner.co.il> writes: > 51-edk2-ovmf-2m-raw-x64-nosb.json is very similar to a file shipped by > qemu, in the sources in pc-bios/descriptors¹. Indeed, I found out the firmwares currently bundled with QEMU (see bug#77092) come with firmware descriptors. Are you suggesting we use these instead? I don't mind too much, except that's a lot of source to unpack to grab a template file, which seems inefficient to me, and that accessing source archives is a bit annoying currently in Guix (because it may be a tarball, or a directory, or it may change if patches get later added... but that's an issue for another time). [...] >> diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm >> index 63f767f72b..c1d8ba3719 100644 >> --- a/gnu/packages/firmware.scm >> +++ b/gnu/packages/firmware.scm >> @@ -1001,6 +1001,10 @@ (define* (make-ovmf-firmware arch) >> (license (list license:expat >> license:bsd-2 license:bsd-3 license:bsd-4))))) >> >> +(define (ovmf-aux-file name) >> + "Return as a gexp the auxiliary OVMF file corresponding to NAME." >> + (local-file (search-auxiliary-file (string-append "ovmf/" name)))) >> + >> (define-public ovmf-x86-64 >> (let ((base (make-ovmf-firmware "x86_64"))) >> (package >> @@ -1022,7 +1026,25 @@ (define-public ovmf-x86-64 >> (string-append fmw "/" (string-downcase file) "_x64.bin"))) >> (list "OVMF" >> "OVMF_CODE" >> - "OVMF_VARS")))))))))))) >> + "OVMF_VARS"))))) > > These 3 files we rename from OVMF* to ovmf*_x64.bin, but based on > roms/edk2-build.config from the qemu sources² OVMF_CODE would become > edk2-x86_64-code.fd. I think we should standardize on using Qemu's > naming scheme for the files. I think we should go ever farther and standardize on *not* renaming them at all. This would remove the arbitrary nature of renaming them to something else that is bound to surprise users. On most distributions they are kept under their original names. The JSON firmware metadata/descriptors files can refer to any name anyway, so outside of following conventions, the name is not too important. But I'd prefer to keep this renaming business for another time, perhaps when I get to add more UEFI firmware variants (at which point it may be more efficient to build them all at once and split them in various outputs). > Also we currently install these files to %output/share/firmware and > there are other files we install to %output/share/qemu and we should > probably standardize between them. The location of the files should match the prevalent convention, which I think is share/firmware. QEMU firmware metadata files on the other hand must be under share/qemu/firmware/, as this is where libvirt expects to find them (actually it won't because we aren't FHS, but that's where it would otherwise :-)). >> + (add-after 'install 'install-qemu-firmware-metadata >> + (lambda _ >> + ;; The QEMU firmware metadata files are taken from the >> + ;; Fedora project (see: >> + ;; https://src.fedoraproject.org/rpms/edk2/tree/rawhide). >> + (let ((51-edk2-ovmf-2m-raw-x64-nosb.json-source >> + #$(ovmf-aux-file "51-edk2-ovmf-2m-raw-x64-nosb.json")) >> + (51-edk2-ovmf-2m-raw-x64-nosb.json-dest >> + (string-append #$output "/share/qemu/firmware/" >> + "51-edk2-ovmf-2m-raw-x64-nosb.json"))) >> + (mkdir-p (dirname 51-edk2-ovmf-2m-raw-x64-nosb.json-dest)) >> + (copy-file 51-edk2-ovmf-2m-raw-x64-nosb.json-source >> + 51-edk2-ovmf-2m-raw-x64-nosb.json-dest) >> + (substitute* 51-edk2-ovmf-2m-raw-x64-nosb.json-dest >> + (("/usr/share/edk2/ovmf/OVMF_(CODE|VARS).fd" _ kind) >> + (string-append >> + #$output "/share/firmware/ovmf_" >> + (string-downcase kind) "_x64.bin"))))))))))))) > > Would it be possible to instead use the search-path to find the > firmwares or is that not really possible? Libvirt has no search path for that. IIRC, it uses $XDG_CONFIG_HOME/qemu/firmware if you run it as a simple user, and otherwise /usr/share/qemu/firmware on FHS, with /etc/qemu/firmware as a fallback to discover the firmware metadata files for QEMU.
On Thu, Mar 20, 2025 at 03:48:34PM +0900, Maxim Cournoyer wrote: > Hi Efraim, > > Efraim Flashner <efraim@flashner.co.il> writes: > > > 51-edk2-ovmf-2m-raw-x64-nosb.json is very similar to a file shipped by > > qemu, in the sources in pc-bios/descriptors¹. > > Indeed, I found out the firmwares currently bundled with QEMU (see > bug#77092) come with firmware descriptors. Are you suggesting we use > these instead? I don't mind too much, except that's a lot of source to > unpack to grab a template file, which seems inefficient to me, and that > accessing source archives is a bit annoying currently in Guix (because > it may be a tarball, or a directory, or it may change if patches get > later added... but that's an issue for another time). It looks like they're also installed in $out/share/qemu/firmware. At that point they have their paths pointing to qemu's location for the firmware, but we could change that at build time to point to firmware we've built or as part of a service to point to a different location. Reminding myself again that we're looking at the firmware itself, I think we shouldn't install a VM configuration file as part of the firmware. > [...] > > >> diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm > >> index 63f767f72b..c1d8ba3719 100644 > >> --- a/gnu/packages/firmware.scm > >> +++ b/gnu/packages/firmware.scm > >> @@ -1001,6 +1001,10 @@ (define* (make-ovmf-firmware arch) > >> (license (list license:expat > >> license:bsd-2 license:bsd-3 license:bsd-4))))) > >> > >> +(define (ovmf-aux-file name) > >> + "Return as a gexp the auxiliary OVMF file corresponding to NAME." > >> + (local-file (search-auxiliary-file (string-append "ovmf/" name)))) > >> + > >> (define-public ovmf-x86-64 > >> (let ((base (make-ovmf-firmware "x86_64"))) > >> (package > >> @@ -1022,7 +1026,25 @@ (define-public ovmf-x86-64 > >> (string-append fmw "/" (string-downcase file) "_x64.bin"))) > >> (list "OVMF" > >> "OVMF_CODE" > >> - "OVMF_VARS")))))))))))) > >> + "OVMF_VARS"))))) > > > > These 3 files we rename from OVMF* to ovmf*_x64.bin, but based on > > roms/edk2-build.config from the qemu sources² OVMF_CODE would become > > edk2-x86_64-code.fd. I think we should standardize on using Qemu's > > naming scheme for the files. > > I think we should go ever farther and standardize on *not* renaming them > at all. This would remove the arbitrary nature of renaming them to > something else that is bound to surprise users. On most distributions > they are kept under their original names. The JSON firmware > metadata/descriptors files can refer to any name anyway, so outside of > following conventions, the name is not too important. > > But I'd prefer to keep this renaming business for another time, perhaps > when I get to add more UEFI firmware variants (at which point it may be > more efficient to build them all at once and split them in various > outputs). Sounds like a good idea. > > Also we currently install these files to %output/share/firmware and > > there are other files we install to %output/share/qemu and we should > > probably standardize between them. > > The location of the files should match the prevalent convention, which I > think is share/firmware. QEMU firmware metadata files on the other hand > must be under share/qemu/firmware/, as this is where libvirt expects to > find them (actually it won't because we aren't FHS, but that's where it > would otherwise :-)). > > >> + (add-after 'install 'install-qemu-firmware-metadata > >> + (lambda _ > >> + ;; The QEMU firmware metadata files are taken from the > >> + ;; Fedora project (see: > >> + ;; https://src.fedoraproject.org/rpms/edk2/tree/rawhide). > >> + (let ((51-edk2-ovmf-2m-raw-x64-nosb.json-source > >> + #$(ovmf-aux-file "51-edk2-ovmf-2m-raw-x64-nosb.json")) > >> + (51-edk2-ovmf-2m-raw-x64-nosb.json-dest > >> + (string-append #$output "/share/qemu/firmware/" > >> + "51-edk2-ovmf-2m-raw-x64-nosb.json"))) > >> + (mkdir-p (dirname 51-edk2-ovmf-2m-raw-x64-nosb.json-dest)) > >> + (copy-file 51-edk2-ovmf-2m-raw-x64-nosb.json-source > >> + 51-edk2-ovmf-2m-raw-x64-nosb.json-dest) > >> + (substitute* 51-edk2-ovmf-2m-raw-x64-nosb.json-dest > >> + (("/usr/share/edk2/ovmf/OVMF_(CODE|VARS).fd" _ kind) > >> + (string-append > >> + #$output "/share/firmware/ovmf_" > >> + (string-downcase kind) "_x64.bin"))))))))))))) > > > > Would it be possible to instead use the search-path to find the > > firmwares or is that not really possible? > > Libvirt has no search path for that. IIRC, it uses > $XDG_CONFIG_HOME/qemu/firmware if you run it as a simple user, and > otherwise /usr/share/qemu/firmware on FHS, with /etc/qemu/firmware as a > fallback to discover the firmware metadata files for QEMU. The libvirt service does have a qemu field. Perhaps we could make use of that somehow? > -- > Thanks, > Maxim
Hi Efraim, Efraim Flashner <efraim@flashner.co.il> writes: > On Thu, Mar 20, 2025 at 03:48:34PM +0900, Maxim Cournoyer wrote: >> Hi Efraim, >> >> Efraim Flashner <efraim@flashner.co.il> writes: >> >> > 51-edk2-ovmf-2m-raw-x64-nosb.json is very similar to a file shipped by >> > qemu, in the sources in pc-bios/descriptors¹. >> >> Indeed, I found out the firmwares currently bundled with QEMU (see >> bug#77092) come with firmware descriptors. Are you suggesting we use >> these instead? I don't mind too much, except that's a lot of source to >> unpack to grab a template file, which seems inefficient to me, and that >> accessing source archives is a bit annoying currently in Guix (because >> it may be a tarball, or a directory, or it may change if patches get >> later added... but that's an issue for another time). > > It looks like they're also installed in $out/share/qemu/firmware. At > that point they have their paths pointing to qemu's location for the > firmware, but we could change that at build time to point to firmware > we've built or as part of a service to point to a different location. > > Reminding myself again that we're looking at the firmware itself, I > think we shouldn't install a VM configuration file as part of the > firmware. That's what most distributions appears to do, for example Fedora [0], and it makes sense to me. QEMU itself should come without firmwares if we want to keep its size in check, and it can't include the descriptor files if it doesn't ship the firmware as the descriptor files reference the file names (well, we could point to some place where they eventually land, and have this provisioned by a service, but that's inelegant). [0] https://src.fedoraproject.org/rpms/edk2/blob/rawhide/f/edk2.spec#_569 [...] >> Libvirt has no search path for that. IIRC, it uses >> $XDG_CONFIG_HOME/qemu/firmware if you run it as a simple user, and >> otherwise /usr/share/qemu/firmware on FHS, with /etc/qemu/firmware as a >> fallback to discover the firmware metadata files for QEMU. > > The libvirt service does have a qemu field. Perhaps we could make use of > that somehow? It's useful to have qemu a distinct field to firmwares; it points to the qemu package/binary used by libvirt while firmwares allow you to specify which firmware files are made available. Note that since QEMU currently bundles many firmwares with their descriptors, you can currently add 'qemu' to the list of firmwares and it'll make them available to libvirt (though I wouldn't advertise this too much as the goal should be to move them to their own distinct packages).
Hi, I've now applied this series, thank you for reviewing it!
diff --git a/Makefile.am b/Makefile.am index c668b96a37..f2f4a9643e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -472,6 +472,7 @@ AUX_FILES = \ gnu/packages/aux-files/linux-libre/5.4-arm64.conf \ gnu/packages/aux-files/linux-libre/5.4-i686.conf \ gnu/packages/aux-files/linux-libre/5.4-x86_64.conf \ + gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json \ gnu/packages/aux-files/pack-audit.c \ gnu/packages/aux-files/python/sanity-check.py \ gnu/packages/aux-files/python/sitecustomize.py \ diff --git a/gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json b/gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json new file mode 100644 index 0000000000..050853e2b8 --- /dev/null +++ b/gnu/packages/aux-files/ovmf/51-edk2-ovmf-2m-raw-x64-nosb.json @@ -0,0 +1,36 @@ +{ + "description": "OVMF without SB+SMM, empty varstore", + "interface-types": [ + "uefi" + ], + "mapping": { + "device": "flash", + "mode" : "split", + "executable": { + "filename": "/usr/share/edk2/ovmf/OVMF_CODE.fd", + "format": "raw" + }, + "nvram-template": { + "filename": "/usr/share/edk2/ovmf/OVMF_VARS.fd", + "format": "raw" + } + }, + "targets": [ + { + "architecture": "x86_64", + "machines": [ + "pc-i440fx-*", + "pc-q35-*" + ] + } + ], + "features": [ + "acpi-s3", + "amd-sev", + "amd-sev-es", + "verbose-dynamic" + ], + "tags": [ + + ] +} diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm index 63f767f72b..c1d8ba3719 100644 --- a/gnu/packages/firmware.scm +++ b/gnu/packages/firmware.scm @@ -1001,6 +1001,10 @@ (define* (make-ovmf-firmware arch) (license (list license:expat license:bsd-2 license:bsd-3 license:bsd-4))))) +(define (ovmf-aux-file name) + "Return as a gexp the auxiliary OVMF file corresponding to NAME." + (local-file (search-auxiliary-file (string-append "ovmf/" name)))) + (define-public ovmf-x86-64 (let ((base (make-ovmf-firmware "x86_64"))) (package @@ -1022,7 +1026,25 @@ (define-public ovmf-x86-64 (string-append fmw "/" (string-downcase file) "_x64.bin"))) (list "OVMF" "OVMF_CODE" - "OVMF_VARS")))))))))))) + "OVMF_VARS"))))) + (add-after 'install 'install-qemu-firmware-metadata + (lambda _ + ;; The QEMU firmware metadata files are taken from the + ;; Fedora project (see: + ;; https://src.fedoraproject.org/rpms/edk2/tree/rawhide). + (let ((51-edk2-ovmf-2m-raw-x64-nosb.json-source + #$(ovmf-aux-file "51-edk2-ovmf-2m-raw-x64-nosb.json")) + (51-edk2-ovmf-2m-raw-x64-nosb.json-dest + (string-append #$output "/share/qemu/firmware/" + "51-edk2-ovmf-2m-raw-x64-nosb.json"))) + (mkdir-p (dirname 51-edk2-ovmf-2m-raw-x64-nosb.json-dest)) + (copy-file 51-edk2-ovmf-2m-raw-x64-nosb.json-source + 51-edk2-ovmf-2m-raw-x64-nosb.json-dest) + (substitute* 51-edk2-ovmf-2m-raw-x64-nosb.json-dest + (("/usr/share/edk2/ovmf/OVMF_(CODE|VARS).fd" _ kind) + (string-append + #$output "/share/firmware/ovmf_" + (string-downcase kind) "_x64.bin"))))))))))))) (define-public ovmf-i686 (let ((base (make-ovmf-firmware "i686")))