+ Since 7.2.0 QEMU/KVM only
+-
+- When used together with firmware
attribute of
+- os
element the type
attribute must
+- have the same value.
+-
+-
+- List of mandatory attributes:
+-
+- -
+-
type
(accepted values are bios
+- and efi
) same as the firmware
+- attribute of os
element.
+-
+-
+-
+
+ When using firmware auto-selection there are different features
+ enabled in the firmwares. The list of features can be used to
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index b7f6a6b494..ec8167e588 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -270,13 +270,7 @@
+
+
+
+-
+-
+- bios
+- efi
+-
+-
+-
++
+
+
+
+@@ -288,7 +282,7 @@
+
+
+
+-
++
+
+
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 2ffa9c8a2a..6806064016 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -19389,31 +19389,21 @@ virDomainDefParseBootFirmwareOptions(virDomainDefPtr def,
+ xmlXPathContextPtr ctxt)
+ {
+ g_autofree char *firmware = virXPathString("string(./os/@firmware)", ctxt);
+- g_autofree char *type = virXPathString("string(./os/firmware/@type)", ctxt);
+ g_autofree xmlNodePtr *nodes = NULL;
+ g_autofree int *features = NULL;
+ int fw = 0;
+ int n = 0;
+ size_t i;
+
+- if (!firmware && !type)
++ if (!firmware)
+ return 0;
+
+- if (firmware && type && STRNEQ(firmware, type)) {
+- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+- _("firmware attribute and firmware type has to be the same"));
+- return -1;
+- }
+-
+- if (!type)
+- type = g_steal_pointer(&firmware);
+-
+- fw = virDomainOsDefFirmwareTypeFromString(type);
++ fw = virDomainOsDefFirmwareTypeFromString(firmware);
+
+ if (fw <= 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unknown firmware value %s"),
+- type);
++ firmware);
+ return -1;
+ }
+
+@@ -29039,30 +29029,22 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
+ virBufferAsprintf(buf, ">%s\n",
+ virDomainOSTypeToString(def->os.type));
+
+- if (def->os.firmware) {
+- virBufferAsprintf(buf, "os.firmware));
+-
+- if (def->os.firmwareFeatures) {
+- virBufferAddLit(buf, ">\n");
+-
+- virBufferAdjustIndent(buf, 2);
++ if (def->os.firmwareFeatures) {
++ virBufferAddLit(buf, "\n");
++ virBufferAdjustIndent(buf, 2);
+
+- for (i = 0; i < VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST; i++) {
+- if (def->os.firmwareFeatures[i] == VIR_TRISTATE_BOOL_ABSENT)
+- continue;
++ for (i = 0; i < VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST; i++) {
++ if (def->os.firmwareFeatures[i] == VIR_TRISTATE_BOOL_ABSENT)
++ continue;
+
+- virBufferAsprintf(buf, "\n",
+- virTristateBoolTypeToString(def->os.firmwareFeatures[i]),
+- virDomainOsDefFirmwareFeatureTypeToString(i));
+- }
++ virBufferAsprintf(buf, "\n",
++ virTristateBoolTypeToString(def->os.firmwareFeatures[i]),
++ virDomainOsDefFirmwareFeatureTypeToString(i));
++ }
+
+- virBufferAdjustIndent(buf, -2);
++ virBufferAdjustIndent(buf, -2);
+
+- virBufferAddLit(buf, "\n");
+- } else {
+- virBufferAddLit(buf, "/>\n");
+- }
++ virBufferAddLit(buf, "\n");
+ }
+
+ virBufferEscapeString(buf, "%s\n",
+diff --git a/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml b/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml
+index 7f8f57a859..4999c4f125 100644
+--- a/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml
++++ b/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml
+@@ -6,7 +6,7 @@
+ 1
+
+ hvm
+-
++
+
+
+
+diff --git a/tests/qemuxml2argvdata/os-firmware-invalid-type.xml b/tests/qemuxml2argvdata/os-firmware-invalid-type.xml
+deleted file mode 100644
+index 41360df0f7..0000000000
+--- a/tests/qemuxml2argvdata/os-firmware-invalid-type.xml
++++ /dev/null
+@@ -1,28 +0,0 @@
+-
+- fedora
+- 63840878-0deb-4095-97e6-fc444d9bc9fa
+- 8192
+- 8192
+- 1
+-
+- hvm
+-
+-
+- /var/lib/libvirt/qemu/nvram/fedora_VARS.fd
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- destroy
+- restart
+- restart
+-
+- /usr/bin/qemu-system-x86_64
+-
+-
+-
+diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
+index 5e16d7fd31..be8054fa6a 100644
+--- a/tests/qemuxml2argvtest.c
++++ b/tests/qemuxml2argvtest.c
+@@ -3095,7 +3095,6 @@ mymain(void)
+ DO_TEST_CAPS_LATEST("os-firmware-efi");
+ DO_TEST_CAPS_LATEST("os-firmware-efi-secboot");
+ DO_TEST_CAPS_LATEST("os-firmware-efi-no-enrolled-keys");
+- DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-invalid-type");
+ DO_TEST_CAPS_ARCH_LATEST("aarch64-os-firmware-efi", "aarch64");
+
+ DO_TEST_CAPS_LATEST("vhost-user-vga");
+diff --git a/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml b/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml
+index 3cac8fc5c6..1e51d55305 100644
+--- a/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml
++++ b/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml
+@@ -6,7 +6,6 @@
+ 1
+
+ hvm
+-
+ /aarch64.kernel
+ /aarch64.initrd
+ earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait
+diff --git a/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml b/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml
+index ef24f2fece..60d3498765 100644
+--- a/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml
++++ b/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml
+@@ -6,7 +6,6 @@
+ 1
+
+ hvm
+-
+
+ /var/lib/libvirt/qemu/nvram/fedora_VARS.fd
+
+diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml b/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml
+index 3757191e8e..938da73711 100644
+--- a/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml
++++ b/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml
+@@ -6,7 +6,6 @@
+ 1
+
+ hvm
+-
+
+ /var/lib/libvirt/qemu/nvram/fedora_VARS.fd
+
+diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml b/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml
+index f2e6b7f36d..97ce8a75c7 100644
+--- a/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml
++++ b/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml
+@@ -6,7 +6,6 @@
+ 1
+
+ hvm
+-
+
+ /var/lib/libvirt/qemu/nvram/fedora_VARS.fd
+
+diff --git a/tests/vmx2xmldata/vmx2xml-firmware-efi.xml b/tests/vmx2xmldata/vmx2xml-firmware-efi.xml
+index 375c47d281..e21158cebf 100644
+--- a/tests/vmx2xmldata/vmx2xml-firmware-efi.xml
++++ b/tests/vmx2xmldata/vmx2xml-firmware-efi.xml
+@@ -5,7 +5,6 @@
+ 1
+
+ hvm
+-
+
+
+ destroy
+--
+2.31.1
+
diff --git a/SOURCES/libvirt-conf-use-switch-in-virDomainDefParseBootOptions.patch b/SOURCES/libvirt-conf-use-switch-in-virDomainDefParseBootOptions.patch
new file mode 100644
index 0000000..e4a8822
--- /dev/null
+++ b/SOURCES/libvirt-conf-use-switch-in-virDomainDefParseBootOptions.patch
@@ -0,0 +1,89 @@
+From 75470b7c297be9bdd712282b89c48465dbe8d400 Mon Sep 17 00:00:00 2001
+Message-Id: <75470b7c297be9bdd712282b89c48465dbe8d400@dist-git>
+From: Pavel Hrdina
+Date: Fri, 21 May 2021 14:16:10 +0200
+Subject: [PATCH] conf: use switch in virDomainDefParseBootOptions
+
+The original code used a lot of conditions and was not that obvious
+when each XML bits are parsed.
+
+Signed-off-by: Pavel Hrdina
+Reviewed-by: Michal Privoznik
+(cherry picked from commit 6330be1ba3af5c4d2150fe2b831f7bc5d87c6d2a)
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1929357
+
+Signed-off-by: Pavel Hrdina
+Message-Id: <900c870b1720688123ed7b69850548ae308ea9a8.1621599207.git.phrdina@redhat.com>
+Reviewed-by: Michal Privoznik
+---
+ src/conf/domain_conf.c | 42 ++++++++++++++++++++++++++----------------
+ 1 file changed, 26 insertions(+), 16 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index f8d8d33245..93a78f8277 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -19483,33 +19483,43 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
+ * - An init script (exe)
+ */
+
+- if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
+- if (virDomainDefParseBootInitOptions(def, ctxt) < 0)
+- return -1;
+- }
+-
+- if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+- def->os.type == VIR_DOMAIN_OSTYPE_XENPVH ||
+- def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
+- def->os.type == VIR_DOMAIN_OSTYPE_UML) {
+-
++ switch ((virDomainOSType) def->os.type) {
++ case VIR_DOMAIN_OSTYPE_HVM:
+ virDomainDefParseBootKernelOptions(def, ctxt);
+
+- if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
+- if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0)
+- return -1;
+- }
++ if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0)
++ return -1;
+
+ if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0)
+ return -1;
+- }
+
+- if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
+ if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0)
+ return -1;
+
+ if (virDomainDefParseBootXML(ctxt, def) < 0)
+ return -1;
++
++ break;
++
++ case VIR_DOMAIN_OSTYPE_XEN:
++ case VIR_DOMAIN_OSTYPE_XENPVH:
++ case VIR_DOMAIN_OSTYPE_UML:
++ virDomainDefParseBootKernelOptions(def, ctxt);
++
++ if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0)
++ return -1;
++
++ break;
++
++ case VIR_DOMAIN_OSTYPE_EXE:
++ if (virDomainDefParseBootInitOptions(def, ctxt) < 0)
++ return -1;
++
++ break;
++
++ case VIR_DOMAIN_OSTYPE_LINUX:
++ case VIR_DOMAIN_OSTYPE_LAST:
++ break;
+ }
+
+ return 0;
+--
+2.31.1
+
diff --git a/SOURCES/libvirt-docs-improve-description-of-secure-attribute-for-loader-element.patch b/SOURCES/libvirt-docs-improve-description-of-secure-attribute-for-loader-element.patch
new file mode 100644
index 0000000..9114b14
--- /dev/null
+++ b/SOURCES/libvirt-docs-improve-description-of-secure-attribute-for-loader-element.patch
@@ -0,0 +1,47 @@
+From 3398815aa337278fe4085f06f3586b2a1a98ab3d Mon Sep 17 00:00:00 2001
+Message-Id: <3398815aa337278fe4085f06f3586b2a1a98ab3d@dist-git>
+From: Pavel Hrdina
+Date: Fri, 21 May 2021 14:16:04 +0200
+Subject: [PATCH] docs: improve description of secure attribute for loader
+ element
+
+The original text was not explaining what this attribute actually
+controls and could have been interpreted as a control switch for the
+Secure boot feature in firmwares.
+
+Signed-off-by: Pavel Hrdina
+Reviewed-by: Kashyap Chamarthy
+Reviewed-by: Michal Privoznik
+(cherry picked from commit f47d06260b9698f705ab2c079c573f89f832e376)
+
+Conflicts:
+ docs/formatdomain.rst
+ - we still have formatdomain.html.in in downstream
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1929357
+
+Signed-off-by: Pavel Hrdina
+Message-Id:
+Reviewed-by: Michal Privoznik
+---
+ docs/formatdomain.html.in | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index 7ac9523684..a40bed347b 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -197,7 +197,9 @@
+ path points to an UEFI image, type
should be
+ pflash
. Moreover, some firmwares may
+ implement the Secure boot feature. Attribute
+- secure
can be used then to control it.
++ secure
can be used to tell the hypervisor that the
++ firmware is capable of Secure Boot feature. It cannot be used to
++ enable or disable the feature itself in the firmware.
+ Since 2.1.0
+