]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_firmware: Refactor setting NVRAM format
authorAndrea Bolognani <abologna@redhat.com>
Wed, 17 Dec 2025 00:12:35 +0000 (01:12 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 8 Jan 2026 23:26:16 +0000 (00:26 +0100)
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>
src/qemu/qemu_firmware.c

index a7bb8f7e4588711c04f6f6356b19b3b0876dab9d..f32e46cc8c07f95f25710d35bb3c43cef317af97 100644 (file)
@@ -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);