From 2eb22e3d0f8013e438813b1a2c5f8b1e020fcde2 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 18 Mar 2025 11:08:39 +0900 Subject: services: libvirt: Add UEFI firmware support. This makes libvirt able to boot images that require a UEFI bootloader, with the available firmwares exposed to libvirt made configurable via a new configuration field. For more background on the problem this fixes, see the same issue that was reported in NixOS (see: https://github.com/NixOS/nixpkgs/issues/115996). * gnu/services/virtualization.scm: (list-of-file-likes?): New predicate. (libvirt-configuration): [firmwares]: New field. (/etc/qemu/firmware): New procedure. (libvirt-service-type): Extend the etc-service-type with it. (generate-libvirt-documentation): Delete obsolete procedure. * doc/guix.texi: Re-generate doc. * gnu/tests/virtualization.scm (run-libvirt-test): Augment memory from 256 to 512 MiB. Test it. Series-to: 77110@debbugs.gnu.org Change-Id: I40694964405f13681520bf1e28b7365b0200d8f7 --- gnu/tests/virtualization.scm | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'gnu/tests/virtualization.scm') diff --git a/gnu/tests/virtualization.scm b/gnu/tests/virtualization.scm index a3c9c4014b3..e08f66eb281 100644 --- a/gnu/tests/virtualization.scm +++ b/gnu/tests/virtualization.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Pierre Langlois ;;; Copyright © 2022 Marius Bakke +;;; Copyright © 2025 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -69,7 +70,8 @@ (define vm (virtual-machine (operating-system os) - (port-forwardings '()))) + (port-forwardings '()) + (memory-size 512))) (define test (with-imported-modules '((gnu build marionette)) @@ -135,6 +137,35 @@ "-c" "qemu:///system" "net-start" "default")) marionette)) + (test-assert "configured firmwares are available to libvirt" + (marionette-eval + '(begin + (use-modules (ice-9 popen) + (ice-9 textual-ports) + (srfi srfi-1) + (srfi srfi-26)) + (let* ((conf-firmwares (list #$@(libvirt-configuration-firmwares + (libvirt-configuration)))) + (virsh #$(file-append libvirt "/bin/virsh")) + (input-pipe (open-pipe* + OPEN_READ + virsh "-c" "qemu:///system" + "domcapabilities" "--xpath" + "/domainCapabilities/os/loader/value/text()")) + (output (get-string-all input-pipe)) + (found-firmwares (string-split (string-trim-both output) + #\newline))) + (close-pipe input-pipe) + ;; Check that every configured firmware package is covered + ;; by at least by one firmware file available to libvirt. + (every (lambda (conf-firmware) + ;; The firmwares listed by virsh contains their + ;; full file names, not just their package output. + (any (cut string-prefix? conf-firmware <>) + found-firmwares)) + conf-firmwares))) + marionette)) + (test-end)))) (gexp->derivation "libvirt-test" test)) -- cgit v1.3