[PATCH 06/13] firmware: Add 'templateFormat' XML attribute and plumb it in

Peter Krempa posted 13 patches 4 weeks ago
[PATCH 06/13] firmware: Add 'templateFormat' XML attribute and plumb it in
Posted by Peter Krempa 4 weeks ago
Currently the qemu firmware code weirdly depends on the 'format' field
of the nvram image itself to do the auto-selection process as well as
then uses it to declare the actual type to qemu.

As it's not technically required that the template and the on disk image
share the type introduce a 'templateFormat' field which will split off
from the shared purpose of the type and will be used for the selection
and instantiation process, while 'format' will be left for the actual
type of the on disk image.

This patch introduces the field, adds XML infrastructure as well as
plumbs it to the firmware bits.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 docs/formatdomain.rst                         | 10 ++++---
 src/conf/domain_conf.c                        | 21 ++++++++++++++
 src/conf/domain_conf.h                        |  1 +
 src/conf/schemas/domaincommon.rng             | 17 ++++++++---
 src/qemu/qemu_firmware.c                      | 29 +++++++++++++++----
 .../aarch64-virt-graphics.aarch64-latest.xml  |  2 +-
 ...ch64-virt-headless-mmio.aarch64-latest.xml |  2 +-
 .../aarch64-virt-headless.aarch64-latest.xml  |  2 +-
 ...-efi-aarch64.aarch64-latest.abi-update.xml |  2 +-
 ...rmware-auto-efi-aarch64.aarch64-latest.xml |  2 +-
 ...e-auto-efi-enrolled-keys.x86_64-latest.xml |  2 +-
 ...-loader-qcow2-nvram-path.x86_64-latest.xml |  2 +-
 ...-efi-format-loader-qcow2.x86_64-latest.xml |  2 +-
 ...t-loader-raw.aarch64-latest.abi-update.xml |  2 +-
 ...o-efi-format-loader-raw.aarch64-latest.xml |  2 +-
 ...-format-nvram-qcow2-path.x86_64-latest.xml |  2 +-
 ...o-efi-format-nvram-qcow2.x86_64-latest.xml |  2 +-
 ...auto-efi-loader-insecure.x86_64-latest.xml |  2 +-
 ...are-auto-efi-loader-path.x86_64-latest.xml |  2 +-
 ...loader-secure.x86_64-latest.abi-update.xml |  2 +-
 ...e-auto-efi-loader-secure.x86_64-latest.xml |  2 +-
 ...ngarch64.loongarch64-latest.abi-update.xml |  2 +-
 ...uto-efi-loongarch64.loongarch64-latest.xml |  2 +-
 ...uto-efi-no-enrolled-keys.x86_64-latest.xml |  2 +-
 ...ware-auto-efi-no-secboot.x86_64-latest.xml |  2 +-
 ...ware-auto-efi-nvram-file.x86_64-latest.xml |  2 +-
 ...ware-auto-efi-nvram-path.x86_64-latest.xml |  2 +-
 ...-auto-efi-nvram-template.x86_64-latest.xml |  2 +-
 ...-efi-riscv64.riscv64-latest.abi-update.xml |  2 +-
 ...irmware-auto-efi-secboot.x86_64-latest.xml |  2 +-
 ...irmware-auto-efi-smm-off.x86_64-latest.xml |  2 +-
 ...ware-auto-efi.x86_64-latest.abi-update.xml |  2 +-
 .../firmware-auto-efi.x86_64-latest.xml       |  2 +-
 ...fi-aarch64-legacy-paths.aarch64-latest.xml |  2 +-
 ...manual-efi-acpi-aarch64.aarch64-latest.xml |  2 +-
 ...ware-manual-efi-acpi-q35.x86_64-latest.xml |  2 +-
 ...ware-manual-efi-features.x86_64-latest.xml |  2 +-
 ...manual-efi-loader-secure.x86_64-latest.xml |  2 +-
 ...rolled-keys-legacy-paths.x86_64-latest.xml |  2 +-
 ...ual-efi-no-enrolled-keys.x86_64-latest.xml |  2 +-
 ...-no-secboot-legacy-paths.x86_64-latest.xml |  2 +-
 ...re-manual-efi-no-secboot.x86_64-latest.xml |  2 +-
 ...nual-efi-noacpi-aarch64.aarch64-latest.xml |  2 +-
 ...re-manual-efi-nvram-file.x86_64-latest.xml |  2 +-
 ...anual-efi-nvram-template.x86_64-latest.xml |  2 +-
 ...efi-secboot-legacy-paths.x86_64-latest.xml |  2 +-
 ...mware-manual-efi-secboot.x86_64-latest.xml |  2 +-
 .../firmware-manual-efi.x86_64-latest.xml     |  2 +-
 ...f-aarch64-virt-headless.aarch64-latest.xml |  2 +-
 .../hvf-x86_64-q35-headless.x86_64-latest.xml |  2 +-
 .../pvpanic-pci-aarch64.aarch64-latest.xml    |  2 +-
 ...-pci-no-address-aarch64.aarch64-latest.xml |  2 +-
 .../virtio-iommu-aarch64.aarch64-latest.xml   |  2 +-
 53 files changed, 113 insertions(+), 61 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index f6d86b26f4..8a4e643c97 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -271,7 +271,10 @@ harddisk, cdrom, network) determining where to obtain/find the boot image.
    up libvirt copies so called master NVRAM store file either selected by the
    firmware autoselection process or defined in ``qemu.conf``.
    If needed, the ``template`` attribute can be used to override the
-   automatically chosen NVRAM template.
+   automatically chosen NVRAM template and ``templateFormat`` to specify the
+   format for the template file (currently supported are ``raw`` and ``qcow2``).
+   When firmware auto-selection is in use the ``templateFormat`` field reflects
+   the format of the picked template. :since:`Since 10.10.0 (QEMU only)`

    Note, that for transient domains if the NVRAM file has been created by
    libvirt it is left behind and it is management application's responsibility
@@ -285,9 +288,8 @@ harddisk, cdrom, network) determining where to obtain/find the boot image.
    **Note:** ``network`` backed NVRAM the variables are not instantiated from
    the ``template`` and it's user's responsibility to provide a valid NVRAM image.

-   This element supports a ``format`` attribute, which has the same semantics
-   as the attribute of the same name for the ``<loader>`` element.
-   :since:`Since 9.2.0 (QEMU only)`
+   This element supports a ``format`` attribute, which specifies the format
+   of the NVRAM image. :since:`Since 9.2.0 (QEMU only)`

    It is not valid to provide this element if the loader is marked as
    stateless.
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4dda943c73..744bc1ac34 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17124,6 +17124,22 @@ virDomainLoaderDefParseXMLNvram(virDomainLoaderDef *loader,

     loader->nvramTemplate = virXMLPropString(nvramNode, "template");

+    if (virXMLPropEnumDefault(nvramNode, "templateFormat",
+                              virStorageFileFormatTypeFromString, VIR_XML_PROP_NONE,
+                              &format, VIR_STORAGE_FILE_NONE) < 0) {
+        return -1;
+    }
+    loader->nvramTemplateFormat = format;
+
+    if (loader->nvramTemplateFormat != VIR_STORAGE_FILE_NONE &&
+        loader->nvramTemplateFormat != VIR_STORAGE_FILE_RAW &&
+        loader->nvramTemplateFormat != VIR_STORAGE_FILE_QCOW2) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Unsupported nvram template format '%1$s'"),
+                       virStorageFileFormatTypeToString(loader->nvramTemplateFormat));
+        return -1;
+    }
+
     if (virXMLPropEnumDefault(nvramNode, "format",
                               virStorageFileFormatTypeFromString, VIR_XML_PROP_NONE,
                               &format, VIR_STORAGE_FILE_NONE) < 0) {
@@ -26796,6 +26812,11 @@ virDomainLoaderDefFormatNvram(virBuffer *buf,

     virBufferEscapeString(&attrBuf, " template='%s'", loader->nvramTemplate);

+    if (loader->nvramTemplateFormat > VIR_STORAGE_FILE_NONE) {
+        virBufferAsprintf(&attrBuf, " templateFormat='%s'",
+                          virStorageFileFormatTypeToString(loader->nvramTemplateFormat));
+    }
+
     if (loader->nvram) {
         virStorageSource *src = loader->nvram;

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a15af4fae3..62de6f1003 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2337,6 +2337,7 @@ struct _virDomainLoaderDef {
     virStorageSource *nvram;
     bool newStyleNVRAM;
     char *nvramTemplate;   /* user override of path to master nvram */
+    virStorageFileFormat nvramTemplateFormat;
 };

 virDomainLoaderDef *virDomainLoaderDefNew(void);
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index efb5f00d77..28797d0122 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -348,6 +348,11 @@
                 <attribute name="template">
                   <ref name="absFilePath"/>
                 </attribute>
+                <optional>
+                  <attribute name="templateFormat">
+                    <ref name="pflashFormatTypes"/>
+                  </attribute>
+                </optional>
               </optional>
               <optional>
                 <ref name="pflashFormat"/>
@@ -7857,12 +7862,16 @@
     </element>
   </define>

+  <define name="pflashFormatTypes">
+    <choice>
+      <value>raw</value>
+      <value>qcow2</value>
+    </choice>
+  </define>
+
   <define name="pflashFormat">
     <attribute name="format">
-      <choice>
-        <value>raw</value>
-        <value>qcow2</value>
-      </choice>
+      <ref name="pflashFormatTypes"/>
     </attribute>
   </define>

diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 5c247b1cf2..d9d21b4771 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -1065,7 +1065,13 @@ qemuFirmwareEnsureNVRAM(virDomainDef *def,

     loader->nvram = virStorageSourceNew();
     loader->nvram->type = VIR_STORAGE_TYPE_FILE;
-    loader->nvram->format = loader->format;
+
+    /* The nvram template format should be always present but as a failsafe,
+     * duplicate the loader format if it is not available. */
+    if (loader->nvramTemplateFormat > VIR_STORAGE_FILE_NONE)
+        loader->nvram->format = loader->nvramTemplateFormat;
+    else
+        loader->nvram->format = loader->format;

     if (loader->nvram->format == VIR_STORAGE_FILE_RAW) {
         /* The extension used by raw edk2 builds has historically
@@ -1422,8 +1428,16 @@ qemuFirmwareEnableFeaturesModern(virDomainDef *def,
              * We can't create or reset non-local NVRAM files, so filling
              * in nvramTemplate for those would be misleading */
             VIR_FREE(loader->nvramTemplate);
-            if (!loader->nvram ||
-                (loader->nvram && virStorageSourceIsLocalStorage(loader->nvram))) {
+            loader->nvramTemplateFormat = VIR_STORAGE_FILE_NONE;
+
+            if (!loader->nvram || virStorageSourceIsLocalStorage(loader->nvram)) {
+                /* validation when parsing the JSON files ensures that we get
+                 * only 'raw' and 'qcow2' here. Fall back to sharing format with loader */
+                if (flash->nvram_template.format)
+                    loader->nvramTemplateFormat = virStorageFileFormatTypeFromString(flash->nvram_template.format);
+                else
+                    loader->nvramTemplateFormat = loader->format;
+
                 loader->nvramTemplate = g_strdup(flash->nvram_template.filename);
             }
         }
@@ -1661,7 +1675,7 @@ qemuFirmwareFillDomainLegacy(virQEMUDriver *driver,
         loader->format = VIR_STORAGE_FILE_RAW;

         /* Only use the default template path if one hasn't been
-         * provided by the user.
+         * provided by the user. Assume that the template is in 'raw' format.
          *
          * In addition to fully-custom templates, which are a valid
          * use case, we could simply be in a situation where
@@ -1682,8 +1696,13 @@ qemuFirmwareFillDomainLegacy(virQEMUDriver *driver,
          * In this case, the global default is to have Secure Boot
          * disabled, but the domain configuration explicitly enables
          * it, and we shouldn't overrule this choice */
-        if (!loader->nvramTemplate)
+        if (!loader->nvramTemplate) {
             loader->nvramTemplate = g_strdup(cfg->firmwares[i]->nvram);
+            loader->nvramTemplateFormat = VIR_STORAGE_FILE_RAW;
+        }
+
+        if (loader->nvramTemplateFormat == VIR_STORAGE_FILE_NONE)
+            loader->nvramTemplateFormat = VIR_STORAGE_FILE_RAW;

         VIR_DEBUG("decided on firmware '%s' template '%s'",
                   loader->path, NULLSTR(loader->nvramTemplate));
diff --git a/tests/qemuxmlconfdata/aarch64-virt-graphics.aarch64-latest.xml b/tests/qemuxmlconfdata/aarch64-virt-graphics.aarch64-latest.xml
index c7bddf4063..f6cfe2b63c 100644
--- a/tests/qemuxmlconfdata/aarch64-virt-graphics.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/aarch64-virt-graphics.aarch64-latest.xml
@@ -16,7 +16,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/path/to/guest_VARS.raw</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/path/to/guest_VARS.raw</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/aarch64-virt-headless-mmio.aarch64-latest.xml b/tests/qemuxmlconfdata/aarch64-virt-headless-mmio.aarch64-latest.xml
index 1b2d6e70bd..56d40b0a9d 100644
--- a/tests/qemuxmlconfdata/aarch64-virt-headless-mmio.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/aarch64-virt-headless-mmio.aarch64-latest.xml
@@ -16,7 +16,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/path/to/guest_VARS.raw</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/path/to/guest_VARS.raw</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/aarch64-virt-headless.aarch64-latest.xml b/tests/qemuxmlconfdata/aarch64-virt-headless.aarch64-latest.xml
index 5029092842..c8fa37a644 100644
--- a/tests/qemuxmlconfdata/aarch64-virt-headless.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/aarch64-virt-headless.aarch64-latest.xml
@@ -16,7 +16,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/path/to/guest_VARS.raw</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/path/to/guest_VARS.raw</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-aarch64.aarch64-latest.abi-update.xml b/tests/qemuxmlconfdata/firmware-auto-efi-aarch64.aarch64-latest.abi-update.xml
index 0088f3324b..1a9baa8cc1 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-aarch64.aarch64-latest.abi-update.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-aarch64.aarch64-latest.abi-update.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash' format='qcow2'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.qcow2</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.qcow2' templateFormat='qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-aarch64.aarch64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-aarch64.aarch64-latest.xml
index 38c680fabd..c6f3a5fe6b 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-aarch64.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-aarch64.aarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-enrolled-keys.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-enrolled-keys.x86_64-latest.xml
index 332d931ba1..729d2d911d 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-enrolled-keys.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-enrolled-keys.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-qcow2-nvram-path.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-qcow2-nvram-path.x86_64-latest.xml
index 49fdfc5c5f..dd044ac091 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-qcow2-nvram-path.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-qcow2-nvram-path.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash' format='qcow2'>/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' format='qcow2'>/path/to/guest_VARS.qcow2</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' templateFormat='qcow2' format='qcow2'>/path/to/guest_VARS.qcow2</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-qcow2.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-qcow2.x86_64-latest.xml
index f4ff7a0fc2..7cdc7eec1f 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-qcow2.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-qcow2.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash' format='qcow2'>/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' templateFormat='qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-raw.aarch64-latest.abi-update.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-raw.aarch64-latest.abi-update.xml
index ee22b16831..195b446a0a 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-raw.aarch64-latest.abi-update.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-raw.aarch64-latest.abi-update.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.raw</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.raw</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-raw.aarch64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-raw.aarch64-latest.xml
index 38c680fabd..c6f3a5fe6b 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-raw.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-loader-raw.aarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-path.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-path.x86_64-latest.xml
index 49fdfc5c5f..dd044ac091 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-path.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-path.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash' format='qcow2'>/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' format='qcow2'>/path/to/guest_VARS.qcow2</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' templateFormat='qcow2' format='qcow2'>/path/to/guest_VARS.qcow2</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2.x86_64-latest.xml
index f4ff7a0fc2..7cdc7eec1f 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash' format='qcow2'>/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' templateFormat='qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-loader-insecure.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-loader-insecure.x86_64-latest.xml
index 4812c4e600..6690c45940 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-loader-insecure.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-loader-insecure.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='no' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-loader-path.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-loader-path.x86_64-latest.xml
index 6b8dc886a6..430613f5fd 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-loader-path.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-loader-path.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-loader-secure.x86_64-latest.abi-update.xml b/tests/qemuxmlconfdata/firmware-auto-efi-loader-secure.x86_64-latest.abi-update.xml
index f4ff7a0fc2..7cdc7eec1f 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-loader-secure.x86_64-latest.abi-update.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-loader-secure.x86_64-latest.abi-update.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash' format='qcow2'>/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' templateFormat='qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-loader-secure.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-loader-secure.x86_64-latest.xml
index 332d931ba1..729d2d911d 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-loader-secure.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-loader-secure.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-loongarch64.loongarch64-latest.abi-update.xml b/tests/qemuxmlconfdata/firmware-auto-efi-loongarch64.loongarch64-latest.abi-update.xml
index 0ae744619f..8ba1bd0f81 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-loongarch64.loongarch64-latest.abi-update.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-loongarch64.loongarch64-latest.abi-update.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/loongarch64/QEMU_EFI.fd</loader>
-    <nvram template='/usr/share/edk2/loongarch64/QEMU_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/loongarch64/QEMU_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-loongarch64.loongarch64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-loongarch64.loongarch64-latest.xml
index 0ae744619f..8ba1bd0f81 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-loongarch64.loongarch64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-loongarch64.loongarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/loongarch64/QEMU_EFI.fd</loader>
-    <nvram template='/usr/share/edk2/loongarch64/QEMU_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/loongarch64/QEMU_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-no-enrolled-keys.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-no-enrolled-keys.x86_64-latest.xml
index 9cf30551a9..53381bd10e 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-no-enrolled-keys.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-no-enrolled-keys.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-no-secboot.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-no-secboot.x86_64-latest.xml
index 6b8dc886a6..430613f5fd 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-no-secboot.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-no-secboot.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-nvram-file.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-nvram-file.x86_64-latest.xml
index ada0411fb3..1672edd458 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-nvram-file.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-nvram-file.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' type='file'>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw' type='file'>
       <source file='/path/to/guest_VARS.fd'/>
     </nvram>
     <boot dev='hd'/>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-nvram-path.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-nvram-path.x86_64-latest.xml
index 135744cb7d..94dd6a29b9 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-nvram-path.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-nvram-path.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/path/to/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd' templateFormat='raw'>/path/to/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-nvram-template.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-nvram-template.x86_64-latest.xml
index 9cf30551a9..53381bd10e 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-nvram-template.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-nvram-template.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-riscv64.riscv64-latest.abi-update.xml b/tests/qemuxmlconfdata/firmware-auto-efi-riscv64.riscv64-latest.abi-update.xml
index d0a60c5bb8..125bd021e7 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-riscv64.riscv64-latest.abi-update.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-riscv64.riscv64-latest.abi-update.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash' format='qcow2'>/usr/share/edk2/riscv/RISCV_VIRT_CODE.qcow2</loader>
-    <nvram template='/usr/share/edk2/riscv/RISCV_VIRT_VARS.qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
+    <nvram template='/usr/share/edk2/riscv/RISCV_VIRT_VARS.qcow2' templateFormat='qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
     <boot dev='hd'/>
   </os>
   <cpu mode='custom' match='exact' check='none'>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-secboot.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-secboot.x86_64-latest.xml
index 332d931ba1..729d2d911d 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-secboot.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-secboot.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-smm-off.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-smm-off.x86_64-latest.xml
index febaad7eae..c53e9f9692 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-smm-off.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-smm-off.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi.x86_64-latest.abi-update.xml b/tests/qemuxmlconfdata/firmware-auto-efi.x86_64-latest.abi-update.xml
index f4ff7a0fc2..7cdc7eec1f 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi.x86_64-latest.abi-update.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi.x86_64-latest.abi-update.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash' format='qcow2'>/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' templateFormat='qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/guest_VARS.qcow2</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi.x86_64-latest.xml
index 332d931ba1..729d2d911d 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
index b53f39a72e..c4ab86c675 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
@@ -7,7 +7,7 @@
   <os>
     <type arch='aarch64' machine='virt-4.0'>hvm</type>
     <loader readonly='yes' type='pflash'>/usr/share/AAVMF/AAVMF_CODE.fd</loader>
-    <nvram template='/usr/share/AAVMF/AAVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/AAVMF/AAVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-acpi-aarch64.aarch64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-acpi-aarch64.aarch64-latest.xml
index 637676d4ed..0dc32d0ce9 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-acpi-aarch64.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-acpi-aarch64.aarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/path/to/guest_VARS.raw</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/path/to/guest_VARS.raw</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-acpi-q35.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-acpi-q35.x86_64-latest.xml
index a4af4ec25a..e7b764b9b0 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-acpi-q35.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-acpi-q35.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/path/to/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/path/to/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-features.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-features.x86_64-latest.xml
index 4d6f2f20aa..67d90c4b1c 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-features.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-features.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-loader-secure.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-loader-secure.x86_64-latest.xml
index 6c3355a3f6..a8c52c9819 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-loader-secure.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-loader-secure.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/path/to/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd' templateFormat='raw'>/path/to/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
index b8c2dfef66..7e2b963537 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
@@ -7,7 +7,7 @@
   <os>
     <type arch='x86_64' machine='pc-q35-4.0'>hvm</type>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/OVMF/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/OVMF/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys.x86_64-latest.xml
index 083562ab0b..dd69b42726 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/path/to/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/path/to/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-no-secboot-legacy-paths.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-no-secboot-legacy-paths.x86_64-latest.xml
index cfd7a6824f..cd48e5e7b9 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-no-secboot-legacy-paths.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-no-secboot-legacy-paths.x86_64-latest.xml
@@ -7,7 +7,7 @@
   <os>
     <type arch='x86_64' machine='pc-q35-4.0'>hvm</type>
     <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/OVMF/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/OVMF/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-no-secboot.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-no-secboot.x86_64-latest.xml
index a4af4ec25a..e7b764b9b0 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-no-secboot.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-no-secboot.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/path/to/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/path/to/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-noacpi-aarch64.aarch64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-noacpi-aarch64.aarch64-latest.xml
index 52f9fac842..fd217afb89 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-noacpi-aarch64.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-noacpi-aarch64.aarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/path/to/guest_VARS.raw</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/path/to/guest_VARS.raw</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-nvram-file.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-nvram-file.x86_64-latest.xml
index ada0411fb3..1672edd458 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-nvram-file.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-nvram-file.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' type='file'>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw' type='file'>
       <source file='/path/to/guest_VARS.fd'/>
     </nvram>
     <boot dev='hd'/>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-nvram-template.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-nvram-template.x86_64-latest.xml
index 4d6f2f20aa..67d90c4b1c 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-nvram-template.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-nvram-template.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-secboot-legacy-paths.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-secboot-legacy-paths.x86_64-latest.xml
index 9027123558..e6db577de4 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-secboot-legacy-paths.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-secboot-legacy-paths.x86_64-latest.xml
@@ -7,7 +7,7 @@
   <os>
     <type arch='x86_64' machine='pc-q35-4.0'>hvm</type>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/OVMF/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/OVMF/OVMF_VARS.secboot.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi-secboot.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi-secboot.x86_64-latest.xml
index 6c3355a3f6..a8c52c9819 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi-secboot.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi-secboot.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/path/to/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd' templateFormat='raw'>/path/to/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/firmware-manual-efi.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-manual-efi.x86_64-latest.xml
index 5bdc9bd4c1..4615cd8db8 100644
--- a/tests/qemuxmlconfdata/firmware-manual-efi.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-manual-efi.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd'>/path/to/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.fd' templateFormat='raw'>/path/to/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/hvf-aarch64-virt-headless.aarch64-latest.xml b/tests/qemuxmlconfdata/hvf-aarch64-virt-headless.aarch64-latest.xml
index dba840237a..f26cce3028 100644
--- a/tests/qemuxmlconfdata/hvf-aarch64-virt-headless.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/hvf-aarch64-virt-headless.aarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/var/lib/libvirt/qemu/nvram/test_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/test_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/hvf-x86_64-q35-headless.x86_64-latest.xml b/tests/qemuxmlconfdata/hvf-x86_64-q35-headless.x86_64-latest.xml
index 6c6c1ea8b0..2291362b53 100644
--- a/tests/qemuxmlconfdata/hvf-x86_64-q35-headless.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/hvf-x86_64-q35-headless.x86_64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='yes' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
-    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/test_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/test_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/pvpanic-pci-aarch64.aarch64-latest.xml b/tests/qemuxmlconfdata/pvpanic-pci-aarch64.aarch64-latest.xml
index d318aa63a1..5db6e99736 100644
--- a/tests/qemuxmlconfdata/pvpanic-pci-aarch64.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/pvpanic-pci-aarch64.aarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/pvpanic-pci-no-address-aarch64.aarch64-latest.xml b/tests/qemuxmlconfdata/pvpanic-pci-no-address-aarch64.aarch64-latest.xml
index 92a81991e2..eabe7c0b4d 100644
--- a/tests/qemuxmlconfdata/pvpanic-pci-no-address-aarch64.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/pvpanic-pci-no-address-aarch64.aarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.xml b/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.xml
index bc6d210458..398ae4e3de 100644
--- a/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.xml
@@ -11,7 +11,7 @@
       <feature enabled='no' name='secure-boot'/>
     </firmware>
     <loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw</loader>
-    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.raw' templateFormat='raw'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
     <boot dev='hd'/>
   </os>
   <features>
-- 
2.47.0