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>
---
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.52.0