File 08101bde-qemu-inline-nvram-path-code.patch of Package libvirt.29155

commit 08101bde5d3f261abe8ef776f032cf800a6ff449
Author: Daniel P. Berrangé <berrange@redhat.com>
Date:   Fri Feb 4 14:30:38 2022 +0000

    qemu: inline code for filling in per-VM NVRAM path
    
    Before creating a NVRAM path, the qemuDomainNVRAMPathGenerate
    method checks whether the config is using the old style
    firmware approach. This check is redundant in one of the two
    callers. By inlining the check into the other caller, it makes
    it clearer to understand that the NVRAM path filling is done
    conditionally.
    
    Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
    Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Index: libvirt-8.0.0/src/qemu/qemu_domain.c
===================================================================
--- libvirt-8.0.0.orig/src/qemu/qemu_domain.c
+++ libvirt-8.0.0/src/qemu/qemu_domain.c
@@ -4441,7 +4441,9 @@ qemuDomainDefPostParse(virDomainDef *def
         def->os.machine = g_strdup(machine);
     }
 
-    qemuDomainNVRAMPathGenerate(cfg, def);
+    if (virDomainDefHasOldStyleROUEFI(def) &&
+        !def->os.loader->nvram)
+        qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram);
 
     if (qemuDomainDefAddDefaultDevices(driver, def, qemuCaps) < 0)
         return -1;
@@ -10979,16 +10981,6 @@ qemuDomainNVRAMPathFormat(virQEMUDriverC
 }
 
 
-void
-qemuDomainNVRAMPathGenerate(virQEMUDriverConfig *cfg,
-                            virDomainDef *def)
-{
-    if (virDomainDefHasOldStyleROUEFI(def) &&
-        !def->os.loader->nvram)
-        qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram);
-}
-
-
 virDomainEventSuspendedDetailType
 qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason)
 {
Index: libvirt-8.0.0/src/qemu/qemu_domain.h
===================================================================
--- libvirt-8.0.0.orig/src/qemu/qemu_domain.h
+++ libvirt-8.0.0/src/qemu/qemu_domain.h
@@ -980,10 +980,6 @@ qemuDomainNVRAMPathFormat(virQEMUDriverC
                             virDomainDef *def,
                             char **path);
 
-void
-qemuDomainNVRAMPathGenerate(virQEMUDriverConfig *cfg,
-                            virDomainDef *def);
-
 virDomainEventSuspendedDetailType
 qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason);
 
Index: libvirt-8.0.0/src/qemu/qemu_firmware.c
===================================================================
--- libvirt-8.0.0.orig/src/qemu/qemu_firmware.c
+++ libvirt-8.0.0/src/qemu/qemu_firmware.c
@@ -1122,11 +1122,12 @@ qemuFirmwareEnableFeatures(virQEMUDriver
         VIR_FREE(def->os.loader->templt);
         def->os.loader->templt = g_strdup(flash->nvram_template.filename);
 
-        qemuDomainNVRAMPathGenerate(cfg, def);
+        qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram);
 
-        VIR_DEBUG("decided on firmware '%s' varstore template '%s'",
+        VIR_DEBUG("decided on firmware '%s' template '%s' NVRAM '%s'",
                   def->os.loader->path,
-                  def->os.loader->templt);
+                  def->os.loader->templt,
+                  def->os.loader->nvram);
         break;
 
     case QEMU_FIRMWARE_DEVICE_KERNEL:
openSUSE Build Service is sponsored by