]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuFirmwareFillDomain: Use FW descriptors to lookup template when resetting NVRAM
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 10 Feb 2022 09:52:47 +0000 (10:52 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 11 Feb 2022 08:03:20 +0000 (09:03 +0100)
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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_firmware.c

index 84c80eaacb1ef62aec1cfa6a25a8d57c6ca62e75..ff364996b824b680b5a4fcae0c06406e0abf416f 100644 (file)
@@ -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,