libvirt/libvirt-qemu_firmware-Refactor-setting-NVRAM-format.patch
2026-04-07 06:32:28 -04:00

54 lines
2.1 KiB
Diff

From d03ee871a69a16ff2975e925150fa361a5b283b4 Mon Sep 17 00:00:00 2001
Message-ID: <d03ee871a69a16ff2975e925150fa361a5b283b4.1772815313.git.jdenemar@redhat.com>
From: Andrea Bolognani <abologna@redhat.com>
Date: Wed, 17 Dec 2025 01:12:35 +0100
Subject: [PATCH] qemu_firmware: Refactor setting NVRAM format
Instead of setting the format every single time, knowing that we
might throw away the entire definition immediately afterwards,
and duplicating a check, only set it if we are going to perform
an early return due to the rest of the definition being properly
filled in already.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit ab8efe6fd076d5e944902e4b2194a7db35a85101)
https://issues.redhat.com/browse/RHEL-82645
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
src/qemu/qemu_firmware.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index a7bb8f7e45..f32e46cc8c 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -985,15 +985,16 @@ qemuFirmwareEnsureNVRAM(virDomainDef *def,
if (loader->stateless == VIR_TRISTATE_BOOL_YES)
return;
- /* If the NVRAM format hasn't been set yet, inherit the same as
- * the loader */
- if (loader->nvram && !loader->nvram->format)
- loader->nvram->format = loader->format;
-
if (loader->nvram) {
- /* Nothing to do if a proper NVRAM backend is already configured */
- if (!virStorageSourceIsEmpty(loader->nvram))
+ /* If a proper NVRAM backend is already configured, we are
+ * done for the most part. We might still need to set the
+ * NVRAM format if that's missing though */
+ if (!virStorageSourceIsEmpty(loader->nvram)) {
+ if (!loader->nvram->format) {
+ loader->nvram->format = loader->format;
+ }
return;
+ }
/* otherwise we want to reset and re-populate the definition */
virObjectUnref(loader->nvram);
--
2.53.0