[PATCH] bhyve: autofill NVRAM data for firmware='efi'

Roman Bogorodskiy posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20250804080947.52969-1-bogorodskiy@gmail.com
src/bhyve/bhyve_firmware.c                              | 5 +++--
tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
[PATCH] bhyve: autofill NVRAM data for firmware='efi'
Posted by Roman Bogorodskiy 1 month ago
When a domain configured with "<os firmware='efi'/>", autofill not only
loader/firmware configuration, but also nvram.

This also fixes the `scripts/domain/405-ovmf-nvram-efi.t` test in
libvirt-tck for bhyve.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 src/bhyve/bhyve_firmware.c                              | 5 +++--
 tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/bhyve/bhyve_firmware.c b/src/bhyve/bhyve_firmware.c
index 36bca490b6..57ad0031b0 100644
--- a/src/bhyve/bhyve_firmware.c
+++ b/src/bhyve/bhyve_firmware.c
@@ -72,8 +72,9 @@ bhyveFirmwareEnsureNVRAM(virDomainDef *def,
         /* otherwise we want to reset and re-populate the definition */
         virObjectUnref(loader->nvram);
     } else {
-        /* Also do nothing if NVRAM is not requested */
-        return;
+        /* Only add nvram for "<os firmware='efi'/>" */
+        if (def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI)
+            return;
     }
 
     loader->nvram = virStorageSourceNew();
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args b/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args
index c87dc7d779..16b9c50535 100644
--- a/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args
@@ -5,7 +5,7 @@ bhyve \
 -H \
 -P \
 -s 0:0,hostbridge \
--l bootrom,fakefirmwaredir/BHYVE_UEFI.fd \
+-l bootrom,fakefirmwaredir/BHYVE_UEFI.fd,fakenvramdir/bhyve_VARS.fd \
 -s 1:0,lpc \
 -s 2:0,ahci,hd:/tmp/freebsd.img \
 -s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
-- 
2.49.0
Re: [PATCH] bhyve: autofill NVRAM data for firmware='efi'
Posted by Michal Prívozník via Devel 2 weeks, 6 days ago
On 8/4/25 10:09, Roman Bogorodskiy wrote:
> When a domain configured with "<os firmware='efi'/>", autofill not only
> loader/firmware configuration, but also nvram.
> 
> This also fixes the `scripts/domain/405-ovmf-nvram-efi.t` test in
> libvirt-tck for bhyve.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  src/bhyve/bhyve_firmware.c                              | 5 +++--
>  tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Michal