[PATCH 2/5] qemuFirmwareFillDomain: Use FW descriptors to lookup template when resetting NVRAM

Michal Privoznik mprivozn at redhat.com
Thu Feb 10 11:13:23 UTC 2022


If VIR_QEMU_PROCESS_START_RESET_NVRAM flag is passed when
starting a domain, then user requested to overwrite the domain
specific NVRAM with the one from template. But it is very likely
that the path to the template is not stored in the domain
definition, which in turn makes the copy function
(qemuPrepareNVRAM()) fail.

The solution is simple - when preparing domain, specifically when
deciding whether the path to the template should be autofilled,
ignore any existing NVRAM file.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_firmware.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 84c80eaacb..ff364996b8 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -1297,6 +1297,7 @@ qemuFirmwareFillDomain(virQEMUDriver *driver,
     ssize_t nfirmwares = 0;
     const qemuFirmware *theone = NULL;
     bool needResult = true;
+    const bool reset_nvram = flags & VIR_QEMU_PROCESS_START_RESET_NVRAM;
     size_t i;
     int ret = -1;
 
@@ -1309,7 +1310,7 @@ qemuFirmwareFillDomain(virQEMUDriver *driver,
          * specified and the varstore doesn't exist ... */
         if (!virDomainDefHasOldStyleROUEFI(def) ||
             def->os.loader->templt ||
-            virFileExists(def->os.loader->nvram))
+            (!reset_nvram && virFileExists(def->os.loader->nvram)))
             return 0;
 
         /* ... then we want to consult JSON FW descriptors first,
-- 
2.34.1




More information about the libvir-list mailing list