++ 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
++ limit what firmware should be automatically selected for the VM.
++ The list of features can be specified using zero or more
++ feature elements. Libvirt will take into consideration
++ only the listed features and ignore the rest when selecting the firmware.
++
++
++
feature
++
++ The list of mandatory attributes:
++
++
++
++ enabled (accepted values are yes
++ and no) is used to tell libvirt if the feature
++ must be enabled or not in the automatically selected firmware
++
++
++ name the name of the feature, the list of the features:
++
++
++ enrolled-keys whether the selected nvram template
++ has default certificate enrolled. Firmware with Secure Boot
++ feature but without enrolled keys will successfully boot
++ non-signed binaries as well. Valid only for firmwares with
++ Secure Boot feature.
++
+- 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-cpu_map-Add-EPYC-Milan-x86-CPU-model.patch b/SOURCES/libvirt-cpu_map-Add-EPYC-Milan-x86-CPU-model.patch
new file mode 100644
index 0000000..3257983
--- /dev/null
+++ b/SOURCES/libvirt-cpu_map-Add-EPYC-Milan-x86-CPU-model.patch
@@ -0,0 +1,145 @@
+From b5716d1b191eb52cd88d7b94cb9bf0186f3e427b Mon Sep 17 00:00:00 2001
+Message-Id:
+From: Jiri Denemark
+Date: Wed, 3 Mar 2021 11:11:54 +0100
+Subject: [PATCH] cpu_map: Add EPYC-Milan x86 CPU model
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Introduced in QEMU 6.0.0 by 623972ceae091b31331ae4a1dc94fe5cbb891937
+
+Signed-off-by: Jiri Denemark
+Reviewed-by: Ján Tomko
+(cherry picked from commit f321a4822e9fa6542e48a78611989ecd9acaa83a)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1926864
+
+Conflicts:
+ src/cpu_map/index.xml
+ - context: commit 82bebba1803c63a733e17f5ab2618e020e4abd8d
+ "cpu_map: Unify apostrophe and quotation mark usage" was
+ not backported
+
+Signed-off-by: Jiri Denemark
+Message-Id: <715abc0f90faafb7daa193dd24bad65046c36de0.1614766279.git.jdenemar@redhat.com>
+Reviewed-by: Ján Tomko
+---
+ src/cpu_map/index.xml | 1 +
+ src/cpu_map/x86_EPYC-Milan.xml | 92 ++++++++++++++++++++++++++++++++++
+ 2 files changed, 93 insertions(+)
+ create mode 100644 src/cpu_map/x86_EPYC-Milan.xml
+
+diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
+index 2f58261e6d..c3dda794b1 100644
+--- a/src/cpu_map/index.xml
++++ b/src/cpu_map/index.xml
+@@ -68,6 +68,7 @@
+
+
+
++
+
+
+
+diff --git a/src/cpu_map/x86_EPYC-Milan.xml b/src/cpu_map/x86_EPYC-Milan.xml
+new file mode 100644
+index 0000000000..53f0cd6aac
+--- /dev/null
++++ b/src/cpu_map/x86_EPYC-Milan.xml
+@@ -0,0 +1,92 @@
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+--
+2.30.0
+
diff --git a/SOURCES/libvirt-cpu_map-Fix-spelling-of-svme-addr-chk-feature.patch b/SOURCES/libvirt-cpu_map-Fix-spelling-of-svme-addr-chk-feature.patch
new file mode 100644
index 0000000..a603df9
--- /dev/null
+++ b/SOURCES/libvirt-cpu_map-Fix-spelling-of-svme-addr-chk-feature.patch
@@ -0,0 +1,59 @@
+From a7fb45c4e5a807a7b437a91cfc96c8c811351578 Mon Sep 17 00:00:00 2001
+Message-Id:
+From: Jiri Denemark
+Date: Thu, 4 Mar 2021 09:41:53 +0100
+Subject: [PATCH] cpu_map: Fix spelling of svme-addr-chk feature
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Commit a208176ca1d9eedf8aa6bf12fde6a7a9579ab549 introduced this feature
+with an incorrect "svme-addr-check" spelling.
+
+Signed-off-by: Jiri Denemark
+Reviewed-by: Tim Wiederhake
+(cherry picked from commit b5abf9a192248b1005f63a7102d2627375d70fe5)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1926864
+
+Conflicts:
+ src/cpu_map/sync_qemu_i386.py
+ - the original change to this file was not backported
+
+Signed-off-by: Jiri Denemark
+Message-Id: <75071287f9fc55f4bec82916726fcb8f31c1e014.1614847231.git.jdenemar@redhat.com>
+Reviewed-by: Ján Tomko
+---
+ src/cpu_map/x86_EPYC-Milan.xml | 2 +-
+ src/cpu_map/x86_features.xml | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/cpu_map/x86_EPYC-Milan.xml b/src/cpu_map/x86_EPYC-Milan.xml
+index 53f0cd6aac..3055e175fa 100644
+--- a/src/cpu_map/x86_EPYC-Milan.xml
++++ b/src/cpu_map/x86_EPYC-Milan.xml
+@@ -76,7 +76,7 @@
+
+
+
+-
++
+
+
+
+diff --git a/src/cpu_map/x86_features.xml b/src/cpu_map/x86_features.xml
+index 8acd42f796..ba23f553c3 100644
+--- a/src/cpu_map/x86_features.xml
++++ b/src/cpu_map/x86_features.xml
+@@ -548,7 +548,7 @@
+
+
+
+-
++
+
+
+
+--
+2.30.0
+
diff --git a/SOURCES/libvirt-cpu_map-Install-x86_EPYC-Milan.xml.patch b/SOURCES/libvirt-cpu_map-Install-x86_EPYC-Milan.xml.patch
new file mode 100644
index 0000000..4652d0e
--- /dev/null
+++ b/SOURCES/libvirt-cpu_map-Install-x86_EPYC-Milan.xml.patch
@@ -0,0 +1,41 @@
+From 8b1e1aa7cb9dc428a36b549a73286ec7040864ed Mon Sep 17 00:00:00 2001
+Message-Id: <8b1e1aa7cb9dc428a36b549a73286ec7040864ed@dist-git>
+From: Jiri Denemark
+Date: Wed, 3 Mar 2021 11:11:55 +0100
+Subject: [PATCH] cpu_map: Install x86_EPYC-Milan.xml
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Jiri Denemark
+Reviewed-by: Pavel Hrdina
+(cherry picked from commit d3de79dbfc20dc4dfc19154b16079861c542b71e)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1926864
+
+Conflicts:
+ src/cpu_map/meson.build
+ - change goes to Makefile.inc.am instead
+
+Signed-off-by: Jiri Denemark
+Message-Id: <77cf69a7222fd9fc5ef0f1c25f0534090c29865f.1614766279.git.jdenemar@redhat.com>
+Reviewed-by: Ján Tomko
+---
+ src/cpu_map/Makefile.inc.am | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/cpu_map/Makefile.inc.am b/src/cpu_map/Makefile.inc.am
+index 1dd78c6715..45dbe9e216 100644
+--- a/src/cpu_map/Makefile.inc.am
++++ b/src/cpu_map/Makefile.inc.am
+@@ -30,6 +30,7 @@ cpumap_DATA = \
+ cpu_map/x86_Dhyana.xml \
+ cpu_map/x86_EPYC.xml \
+ cpu_map/x86_EPYC-IBPB.xml \
++ cpu_map/x86_EPYC-Milan.xml \
+ cpu_map/x86_EPYC-Rome.xml \
+ cpu_map/x86_Haswell.xml \
+ cpu_map/x86_Haswell-IBRS.xml \
+--
+2.30.0
+
diff --git a/SOURCES/libvirt-cpumap-Add-support-for-ibrs-CPU-feature.patch b/SOURCES/libvirt-cpumap-Add-support-for-ibrs-CPU-feature.patch
new file mode 100644
index 0000000..9fcd3a4
--- /dev/null
+++ b/SOURCES/libvirt-cpumap-Add-support-for-ibrs-CPU-feature.patch
@@ -0,0 +1,65 @@
+From bb9f39342d4ea6b76b67378f514f52a9627206b9 Mon Sep 17 00:00:00 2001
+Message-Id:
+From: Tim Wiederhake
+Date: Wed, 3 Mar 2021 11:11:52 +0100
+Subject: [PATCH] cpumap: Add support for ibrs CPU feature
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Tim Wiederhake
+Reviewed-by: Jiri Denemark
+(cherry picked from commit 5c17a7ba41670f3182186c06e621995b5d03fc95)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1926864
+
+Signed-off-by: Jiri Denemark
+Message-Id: <0aee3baa35e04f56e3c95bb2f60c8a17d7806e7a.1614766279.git.jdenemar@redhat.com>
+Reviewed-by: Ján Tomko
+---
+ src/cpu_map/x86_features.xml | 3 +++
+ tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-guest.xml | 1 +
+ tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-host.xml | 1 +
+ 3 files changed, 5 insertions(+)
+
+diff --git a/src/cpu_map/x86_features.xml b/src/cpu_map/x86_features.xml
+index 83d8e641a8..abefb7928e 100644
+--- a/src/cpu_map/x86_features.xml
++++ b/src/cpu_map/x86_features.xml
+@@ -501,6 +501,9 @@
+
+
+
++
++
++
+
+
+
+diff --git a/tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-guest.xml b/tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-guest.xml
+index 6d95b508b2..40e7912398 100644
+--- a/tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-guest.xml
++++ b/tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-guest.xml
+@@ -17,6 +17,7 @@
+
+
+
++
+
+
+
+diff --git a/tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-host.xml b/tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-host.xml
+index 65eaeabdd0..9f8108cdaa 100644
+--- a/tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-host.xml
++++ b/tests/cputestdata/x86_64-cpuid-EPYC-7502-32-Core-host.xml
+@@ -18,6 +18,7 @@
+
+
+
++
+
+
+
+--
+2.30.0
+
diff --git a/SOURCES/libvirt-cpumap-Add-support-for-svme-addr-check-CPU-feature.patch b/SOURCES/libvirt-cpumap-Add-support-for-svme-addr-check-CPU-feature.patch
new file mode 100644
index 0000000..97d1b6f
--- /dev/null
+++ b/SOURCES/libvirt-cpumap-Add-support-for-svme-addr-check-CPU-feature.patch
@@ -0,0 +1,39 @@
+From 87fdbd2d0ab24f00c70a298317d50df44a5f76ad Mon Sep 17 00:00:00 2001
+Message-Id: <87fdbd2d0ab24f00c70a298317d50df44a5f76ad@dist-git>
+From: Tim Wiederhake
+Date: Wed, 3 Mar 2021 11:11:53 +0100
+Subject: [PATCH] cpumap: Add support for svme-addr-check CPU feature
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Tim Wiederhake
+Reviewed-by: Jiri Denemark
+(cherry picked from commit 5ac6ab2fde63881d3c5cc7372a0d0e59618feb55)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1926864
+
+Signed-off-by: Jiri Denemark
+Message-Id:
+Reviewed-by: Ján Tomko
+---
+ src/cpu_map/x86_features.xml | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/cpu_map/x86_features.xml b/src/cpu_map/x86_features.xml
+index abefb7928e..8acd42f796 100644
+--- a/src/cpu_map/x86_features.xml
++++ b/src/cpu_map/x86_features.xml
+@@ -548,6 +548,9 @@
+
+
+
++
++
++
+
+
+
+--
+2.30.0
+
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
+
nvram
+
Some UEFI firmwares may want to use a non-volatile memory to store
+--
+2.31.1
+
diff --git a/SOURCES/libvirt-docs-use-proper-cpu-quota-value-in-our-documentation.patch b/SOURCES/libvirt-docs-use-proper-cpu-quota-value-in-our-documentation.patch
new file mode 100644
index 0000000..abe880f
--- /dev/null
+++ b/SOURCES/libvirt-docs-use-proper-cpu-quota-value-in-our-documentation.patch
@@ -0,0 +1,101 @@
+From c9113d8cd9d68c932175ea63b634fc5cb7e51ef2 Mon Sep 17 00:00:00 2001
+Message-Id:
+From: Pavel Hrdina
+Date: Thu, 4 Mar 2021 12:57:56 +0100
+Subject: [PATCH] docs: use proper cpu quota value in our documentation
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Commit changed the cpu quota
+value that reflects what kernel allows but did not update our
+documentation.
+
+Signed-off-by: Pavel Hrdina
+Reviewed-by: Michal Privoznik
+(cherry picked from commit 992635b142b261cedb6075e459918418fe6e6962)
+
+Conflicts:
+ docs/formatdomain.rst
+ - missing in downstream, we use formatdomain.html.in
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1798463
+
+Signed-off-by: Pavel Hrdina
+Message-Id:
+Reviewed-by: Ján Tomko
+---
+ docs/formatdomain.html.in | 8 ++++----
+ docs/manpages/virsh.rst | 2 +-
+ docs/schemas/domaincommon.rng | 2 +-
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index 127dd13cc0..4341e256a8 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -872,7 +872,7 @@
+ bandwidth (unit: microseconds). A domain with quota as any
+ negative value indicates that the domain has infinite bandwidth for
+ vCPU threads, which means that it is not bandwidth controlled. The value
+- should be in range [1000, 18446744073709551] or less than 0. A quota
++ should be in range [1000, 17592186044415] or less than 0. A quota
+ with value 0 means no value. You can use this feature to ensure that all
+ vCPUs run at the same speed.
+ Only QEMU driver support since 0.9.4, LXC since
+@@ -894,7 +894,7 @@
+ domain. A domain with global_quota as any negative
+ value indicates that the domain has infinite bandwidth, which means that
+ it is not bandwidth controlled. The value should be in range
+- [1000, 18446744073709551] or less than 0. A global_quota
++ [1000, 17592186044415] or less than 0. A global_quota
+ with value 0 means no value.
+ Only QEMU driver support since 1.3.3
+
+@@ -915,7 +915,7 @@
+ excluding vCPUs). A domain with emulator_quota as any negative
+ value indicates that the domain has infinite bandwidth for emulator threads
+ (those excluding vCPUs), which means that it is not bandwidth controlled.
+- The value should be in range [1000, 18446744073709551] or less than 0. A
++ The value should be in range [1000, 17592186044415] or less than 0. A
+ quota with value 0 means no value.
+ Only QEMU driver support since 0.10.0
+
+@@ -937,7 +937,7 @@
+ iothread_quota as any negative value indicates that the
+ domain IOThreads have infinite bandwidth, which means that it is
+ not bandwidth controlled. The value should be in range
+- [1000, 18446744073709551] or less than 0. An iothread_quota
++ [1000, 17592186044415] or less than 0. An iothread_quota
+ with value 0 means no value. You can use this feature to ensure that
+ all IOThreads run at the same speed.
+ Only QEMU driver support since 2.1.0
+diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
+index 0804465d44..a5b95c1123 100644
+--- a/docs/manpages/virsh.rst
++++ b/docs/manpages/virsh.rst
+@@ -3715,7 +3715,7 @@ XEN_CREDIT scheduler.
+ ``Note``: The vcpu_period, emulator_period, and iothread_period parameters
+ have a valid value range of 1000-1000000 or 0, and the vcpu_quota,
+ emulator_quota, and iothread_quota parameters have a valid value range of
+-1000-18446744073709551 or less than 0. The value 0 for
++1000-17592186044415 or less than 0. The value 0 for
+ either parameter is the same as not specifying that parameter.
+
+
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index 4a42cb9b40..6671ef3dfa 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -6649,7 +6649,7 @@
+
+
+ -?[0-9]+
+- 18446744073709551
++ 17592186044415
+ -1
+
+
+--
+2.30.0
+
diff --git a/SOURCES/libvirt-domain_conf-Don-t-leak-def-os.firmwareFeatures.patch b/SOURCES/libvirt-domain_conf-Don-t-leak-def-os.firmwareFeatures.patch
new file mode 100644
index 0000000..431bb2f
--- /dev/null
+++ b/SOURCES/libvirt-domain_conf-Don-t-leak-def-os.firmwareFeatures.patch
@@ -0,0 +1,43 @@
+From 8ad6e3bc6d3e9e55093b546ee886a2a2d9e875f5 Mon Sep 17 00:00:00 2001
+Message-Id: <8ad6e3bc6d3e9e55093b546ee886a2a2d9e875f5@dist-git>
+From: Michal Privoznik
+Date: Fri, 21 May 2021 14:16:13 +0200
+Subject: [PATCH] domain_conf: Don't leak def->os.firmwareFeatures
+
+The firmwareFeatures member of virDomainOSDef struct is allocated
+in virDomainDefParseBootFirmwareOptions() but never freed.
+
+Signed-off-by: Michal Privoznik
+Reviewed-by: Pavel Hrdina
+(cherry picked from commit c116b9481426f86188c71f340d5e3db103120bf8)
+
+Conflicts:
+ src/conf/domain_conf.c
+ - missing upstream commits:
+ 77f8e48fc35eaf867eae4f623e381f87f6e29930
+ f9f81f1c8f855b8c21aeae4441abfc877ff2bfc3
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1929357
+
+Signed-off-by: Pavel Hrdina
+Message-Id: <82f4beea71e682c43ec10370d5a43a608d1cb411.1621599207.git.phrdina@redhat.com>
+Reviewed-by: Michal Privoznik
+---
+ src/conf/domain_conf.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 28c8d0ecbd..2ffa9c8a2a 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -3431,6 +3431,7 @@ void virDomainDefFree(virDomainDefPtr def)
+ VIR_FREE(def->idmap.uidmap);
+ VIR_FREE(def->idmap.gidmap);
+
++ VIR_FREE(def->os.firmwareFeatures);
+ VIR_FREE(def->os.machine);
+ VIR_FREE(def->os.init);
+ for (i = 0; def->os.initargv && def->os.initargv[i]; i++)
+--
+2.31.1
+
diff --git a/SOURCES/libvirt-domain_validate-use-defines-for-cpu-period-and-quota-limits.patch b/SOURCES/libvirt-domain_validate-use-defines-for-cpu-period-and-quota-limits.patch
new file mode 100644
index 0000000..e293dd5
--- /dev/null
+++ b/SOURCES/libvirt-domain_validate-use-defines-for-cpu-period-and-quota-limits.patch
@@ -0,0 +1,85 @@
+From 499e3eb6bdca10a5fac9279261e32e64c28273bd Mon Sep 17 00:00:00 2001
+Message-Id: <499e3eb6bdca10a5fac9279261e32e64c28273bd@dist-git>
+From: Pavel Hrdina
+Date: Thu, 4 Mar 2021 12:57:55 +0100
+Subject: [PATCH] domain_validate: use defines for cpu period and quota limits
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Commints and
+<98a09ca48ed4fc011abf2aa290e02ce1b8f1bb5f> fixed the code to use
+defines instead of magic numbers but missed this place.
+
+Following commit changed
+the cpu quota limit to reflect what kernel actually allows so using
+the defines fixes XML validations as well.
+
+Signed-off-by: Pavel Hrdina
+Reviewed-by: Michal Privoznik
+(cherry picked from commit 22cae2ea4bad7e285ba19d536bd475f8b00841f8)
+
+Conflicts:
+ src/conf/domain_validate.c
+ - not present in downstream, the code is still part of
+ domain_conf.c
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1798463
+
+Signed-off-by: Pavel Hrdina
+Message-Id: <63a44700876e2bd59f276fcd8395abaff011b4c1.1614858616.git.phrdina@redhat.com>
+Reviewed-by: Ján Tomko
+---
+ src/conf/domain_conf.c | 20 +++++++++++++-------
+ 1 file changed, 13 insertions(+), 7 deletions(-)
+
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 166c3e48d2..9f6cdb0de8 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -34,6 +34,7 @@
+ #include "domain_addr.h"
+ #include "domain_conf.h"
+ #include "snapshot_conf.h"
++#include "vircgroup.h"
+ #include "viralloc.h"
+ #include "virxml.h"
+ #include "viruuid.h"
+@@ -6997,10 +6998,13 @@ virDomainDefLifecycleActionValidate(const virDomainDef *def)
+ #define CPUTUNE_VALIDATE_PERIOD(name) \
+ do { \
+ if (def->cputune.name > 0 && \
+- (def->cputune.name < 1000 || def->cputune.name > 1000000)) { \
++ (def->cputune.name < VIR_CGROUP_CPU_PERIOD_MIN || \
++ def->cputune.name > VIR_CGROUP_CPU_PERIOD_MAX)) { \
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
+- _("Value of cputune '%s' must be in range " \
+- "[1000, 1000000]"), #name); \
++ _("Value of cputune '%s' must be in range [%llu, %llu]"), \
++ #name, \
++ VIR_CGROUP_CPU_PERIOD_MIN, \
++ VIR_CGROUP_CPU_PERIOD_MAX); \
+ return -1; \
+ } \
+ } while (0)
+@@ -7008,11 +7012,13 @@ virDomainDefLifecycleActionValidate(const virDomainDef *def)
+ #define CPUTUNE_VALIDATE_QUOTA(name) \
+ do { \
+ if (def->cputune.name > 0 && \
+- (def->cputune.name < 1000 || \
+- def->cputune.name > 18446744073709551LL)) { \
++ (def->cputune.name < VIR_CGROUP_CPU_QUOTA_MIN || \
++ def->cputune.name > VIR_CGROUP_CPU_QUOTA_MAX)) { \
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
+- _("Value of cputune '%s' must be in range " \
+- "[1000, 18446744073709551]"), #name); \
++ _("Value of cputune '%s' must be in range [%llu, %llu]"), \
++ #name, \
++ VIR_CGROUP_CPU_QUOTA_MIN, \
++ VIR_CGROUP_CPU_QUOTA_MAX); \
+ return -1; \
+ } \
+ } while (0)
+--
+2.30.0
+
diff --git a/SOURCES/libvirt-hostdev-Update-mdev-pointer-reference-after-checking-device-type.patch b/SOURCES/libvirt-hostdev-Update-mdev-pointer-reference-after-checking-device-type.patch
new file mode 100644
index 0000000..96deffe
--- /dev/null
+++ b/SOURCES/libvirt-hostdev-Update-mdev-pointer-reference-after-checking-device-type.patch
@@ -0,0 +1,50 @@
+From bad40f7148a5849e84e9cdc341ff1fa03dc94fc6 Mon Sep 17 00:00:00 2001
+Message-Id:
+From: Thomas Huth
+Date: Tue, 11 May 2021 14:10:27 +0200
+Subject: [PATCH] hostdev: Update mdev pointer reference after checking device
+ type
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We set the pointer to some garbage packed structure data without
+knowing whether we were actually handling the type of device we
+expected to be handling. On its own, this was harmless, because we'd
+never use the pointer as we'd skip the device if it were not the
+expected type. However, it's better to make the logic even more
+explicit - we first check the device and only when we're sure we have
+the expected type we then update the pointer shortcut.
+
+Signed-off-by: Erik Skultety
+Reviewed-by: Ján Tomko
+(cherry picked from commit 964738cff3d949d90fc5c3317a2618fcd8d217b4)
+Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1940449
+Signed-off-by: Thomas Huth
+Message-Id: <20210511121028.304070-2-thuth@redhat.com>
+Reviewed-by: Erik Skultety
+---
+ src/util/virhostdev.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
+index 9596482146..b7050e99e4 100644
+--- a/src/util/virhostdev.c
++++ b/src/util/virhostdev.c
+@@ -2030,11 +2030,11 @@ virHostdevReAttachMediatedDevices(virHostdevManagerPtr mgr,
+ virDomainHostdevSubsysMediatedDevPtr mdevsrc;
+ virDomainHostdevDefPtr hostdev = hostdevs[i];
+
+- mdevsrc = &hostdev->source.subsys.u.mdev;
+-
+ if (!virHostdevIsMdevDevice(hostdev))
+ continue;
+
++ mdevsrc = &hostdev->source.subsys.u.mdev;
++
+ if (!(mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
+ mdevsrc->model)))
+ continue;
+--
+2.31.1
+
diff --git a/SOURCES/libvirt-hostdev-mdev-Lookup-mdevs-by-sysfs-path-rather-than-mdev-struct.patch b/SOURCES/libvirt-hostdev-mdev-Lookup-mdevs-by-sysfs-path-rather-than-mdev-struct.patch
new file mode 100644
index 0000000..3b68fb0
--- /dev/null
+++ b/SOURCES/libvirt-hostdev-mdev-Lookup-mdevs-by-sysfs-path-rather-than-mdev-struct.patch
@@ -0,0 +1,166 @@
+From 9e97e35031572e0f6ace32e2fb094f0f358f0391 Mon Sep 17 00:00:00 2001
+Message-Id: <9e97e35031572e0f6ace32e2fb094f0f358f0391@dist-git>
+From: Thomas Huth
+Date: Tue, 11 May 2021 14:10:28 +0200
+Subject: [PATCH] hostdev: mdev: Lookup mdevs by sysfs path rather than mdev
+ struct
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The lookup didn't do anything apart from comparing the sysfs paths
+anyway since that's what makes each mdev unique.
+The most ridiculous usage of the old logic was in
+virHostdevReAttachMediatedDevices where in order to drop an mdev
+hostdev from the list of active devices we first had to create a new
+mdev and use it in the lookup call. Why couldn't we have used the
+hostdev directly? Because the hostdev and mdev structures are
+incompatible.
+
+The way mdevs are currently removed is via a write to a specific sysfs
+attribute. If you do it while the machine which has the mdev assigned
+is running, the write call may block (with a new enough kernel, with
+older kernels it would return a write error!) until the device
+is no longer in use which is when the QEMU process exits.
+
+The interesting part here comes afterwards when we're cleaning up and
+call virHostdevReAttachMediatedDevices. The domain doesn't exist
+anymore, so the list of active hostdevs needs to be updated and the
+respective hostdevs removed from the list, but remember we had to
+create an mdev object in the memory in order to find it in the list
+first which will fail because the write to sysfs had already removed
+the mdev instance from the host system.
+And so the next time you try to start the same domain you'll get:
+
+"Requested operation is not valid: mediated device is in use by
+driver QEMU, domain "
+
+Fixes: https://gitlab.com/libvirt/libvirt/-/issues/119
+
+Signed-off-by: Erik Skultety
+Reviewed-by: Ján Tomko
+(cherry picked from commit 49cb59778a4e6c2d04bb9383a9d97fbbc83f9fce)
+Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1940449
+Signed-off-by: Thomas Huth
+Message-Id: <20210511121028.304070-3-thuth@redhat.com>
+Reviewed-by: Erik Skultety
+---
+ src/util/virhostdev.c | 10 ++++------
+ src/util/virmdev.c | 16 ++++++++--------
+ src/util/virmdev.h | 4 ++--
+ 3 files changed, 14 insertions(+), 16 deletions(-)
+
+diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
+index b7050e99e4..392e94307c 100644
+--- a/src/util/virhostdev.c
++++ b/src/util/virhostdev.c
+@@ -2025,7 +2025,7 @@ virHostdevReAttachMediatedDevices(virHostdevManagerPtr mgr,
+
+ virObjectLock(mgr->activeMediatedHostdevs);
+ for (i = 0; i < nhostdevs; i++) {
+- g_autoptr(virMediatedDevice) mdev = NULL;
++ g_autofree char *sysfspath = NULL;
+ virMediatedDevicePtr tmp;
+ virDomainHostdevSubsysMediatedDevPtr mdevsrc;
+ virDomainHostdevDefPtr hostdev = hostdevs[i];
+@@ -2034,14 +2034,12 @@ virHostdevReAttachMediatedDevices(virHostdevManagerPtr mgr,
+ continue;
+
+ mdevsrc = &hostdev->source.subsys.u.mdev;
+-
+- if (!(mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
+- mdevsrc->model)))
+- continue;
++ sysfspath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr);
+
+ /* Remove from the list only mdevs assigned to @drv_name/@dom_name */
+
+- tmp = virMediatedDeviceListFind(mgr->activeMediatedHostdevs, mdev);
++ tmp = virMediatedDeviceListFind(mgr->activeMediatedHostdevs,
++ sysfspath);
+
+ /* skip inactive devices */
+ if (!tmp)
+diff --git a/src/util/virmdev.c b/src/util/virmdev.c
+index c2499c0a20..bae4a7d2c1 100644
+--- a/src/util/virmdev.c
++++ b/src/util/virmdev.c
+@@ -312,7 +312,7 @@ int
+ virMediatedDeviceListAdd(virMediatedDeviceListPtr list,
+ virMediatedDevicePtr *dev)
+ {
+- if (virMediatedDeviceListFind(list, *dev)) {
++ if (virMediatedDeviceListFind(list, (*dev)->path)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("device %s is already in use"), (*dev)->path);
+ return -1;
+@@ -358,7 +358,7 @@ virMediatedDevicePtr
+ virMediatedDeviceListSteal(virMediatedDeviceListPtr list,
+ virMediatedDevicePtr dev)
+ {
+- int idx = virMediatedDeviceListFindIndex(list, dev);
++ int idx = virMediatedDeviceListFindIndex(list, dev->path);
+
+ return virMediatedDeviceListStealIndex(list, idx);
+ }
+@@ -374,13 +374,13 @@ virMediatedDeviceListDel(virMediatedDeviceListPtr list,
+
+ int
+ virMediatedDeviceListFindIndex(virMediatedDeviceListPtr list,
+- virMediatedDevicePtr dev)
++ const char *sysfspath)
+ {
+ size_t i;
+
+ for (i = 0; i < list->count; i++) {
+- virMediatedDevicePtr other = list->devs[i];
+- if (STREQ(other->path, dev->path))
++ virMediatedDevicePtr dev = list->devs[i];
++ if (STREQ(sysfspath, dev->path))
+ return i;
+ }
+ return -1;
+@@ -389,11 +389,11 @@ virMediatedDeviceListFindIndex(virMediatedDeviceListPtr list,
+
+ virMediatedDevicePtr
+ virMediatedDeviceListFind(virMediatedDeviceListPtr list,
+- virMediatedDevicePtr dev)
++ const char *sysfspath)
+ {
+ int idx;
+
+- if ((idx = virMediatedDeviceListFindIndex(list, dev)) >= 0)
++ if ((idx = virMediatedDeviceListFindIndex(list, sysfspath)) >= 0)
+ return list->devs[idx];
+ else
+ return NULL;
+@@ -407,7 +407,7 @@ virMediatedDeviceIsUsed(virMediatedDevicePtr dev,
+ const char *drvname, *domname;
+ virMediatedDevicePtr tmp = NULL;
+
+- if ((tmp = virMediatedDeviceListFind(list, dev))) {
++ if ((tmp = virMediatedDeviceListFind(list, dev->path))) {
+ virMediatedDeviceGetUsedBy(tmp, &drvname, &domname);
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("mediated device %s is in use by "
+diff --git a/src/util/virmdev.h b/src/util/virmdev.h
+index e0905a3f6e..3022ab9948 100644
+--- a/src/util/virmdev.h
++++ b/src/util/virmdev.h
+@@ -120,11 +120,11 @@ virMediatedDeviceListDel(virMediatedDeviceListPtr list,
+
+ virMediatedDevicePtr
+ virMediatedDeviceListFind(virMediatedDeviceListPtr list,
+- virMediatedDevicePtr dev);
++ const char *sysfspath);
+
+ int
+ virMediatedDeviceListFindIndex(virMediatedDeviceListPtr list,
+- virMediatedDevicePtr dev);
++ const char *sysfspath);
+
+ int
+ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
+--
+2.31.1
+
diff --git a/SOURCES/libvirt-network-force-re-creation-of-iptables-private-chains-on-firewalld-restart.patch b/SOURCES/libvirt-network-force-re-creation-of-iptables-private-chains-on-firewalld-restart.patch
new file mode 100644
index 0000000..f35830d
--- /dev/null
+++ b/SOURCES/libvirt-network-force-re-creation-of-iptables-private-chains-on-firewalld-restart.patch
@@ -0,0 +1,282 @@
+From 021167719bebe7fb7a0e366c371b6c7057ebed7e Mon Sep 17 00:00:00 2001
+Message-Id: <021167719bebe7fb7a0e366c371b6c7057ebed7e@dist-git>
+From: Laine Stump
+Date: Wed, 14 Apr 2021 23:25:34 -0400
+Subject: [PATCH] network: force re-creation of iptables private chains on
+ firewalld restart
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When firewalld is stopped, it removes *all* iptables rules and chains,
+including those added by libvirt. Since restarting firewalld means
+stopping and then starting it, any time it is restarted, libvirt needs
+to recreate all the private iptables chains it uses, along with all
+the rules it adds.
+
+We already have code in place to call networkReloadFirewallRules() any
+time we're notified of a firewalld start, and
+networkReloadFirewallRules() will call
+networkPreReloadFirewallRules(), which calls
+networkSetupPrivateChains(); unfortunately that last call is called
+using virOnce(), meaning that it will only be called the first time
+through networkPreReloadFirewallRules() after libvirtd starts - so of
+course when firewalld is later restarted, the call to
+networkSetupPrivateChains() is skipped.
+
+The neat and tidy way to fix this would be if there was a standard way
+to reset a pthread_once_t object so that the next time virOnce was
+called, it would think the function hadn't been called, and call it
+again. Unfortunately, there isn't any official way of doing that (we
+*could* just fill it with 0 and hope for the best, but that doesn't
+seem very safe.
+
+So instead, this patch just adds a static variable called
+chainInitDone, which is set to true after networkSetupPrivateChains()
+is called for the first time, and then during calls to
+networkPreReloadFirewallRules(), if chainInitDone is set, we call
+networkSetupPrivateChains() directly instead of via virOnce().
+
+It may seem unsafe to directly call a function that is meant to be
+called only once, but I think in this case we're safe - there's
+nothing in the function that is inherently "once only" - it doesn't
+initialize anything that can't safely be re-initialized (as long as
+two threads don't try to do it at the same time), and it only happens
+when responding to a dbus message that firewalld has been started (and
+I don't think it's possible for us to be processing two of those at
+once), and even then only if the initial call to the function has
+already been completed (so we're safe if we receive a firewalld
+restart call at a time when we haven't yet called it, or even if
+another thread is already in the process of executing it. The only
+problematic bit I can think of is if another thread is in the process
+of adding an iptable rule at the time we're executing this function,
+but 1) none of those threads will be trying to add chains, and 2) if
+there was a concurrency problem with other threads adding iptables
+rules while firewalld was being restarted, it would still be a problem
+even without this change.
+
+This is yet another patch that fixes an occurrence of this error:
+
+COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --insert LIBVIRT_INP --in-interface virbr0 --protocol tcp --destination-port 67 --jump ACCEPT' failed: iptables: No chain/target/match by that name.
+
+Signed-off-by: Laine Stump
+Reviewed-by: Daniel P. Berrangé
+(cherry picked from commit f5418b427e7d2f26803880309478de9103680826)
+
+https://bugzilla.redhat.com/1942805
+(cloned from the RHEL-AV version: https://bugzilla.redhat.com/1813830 )
+
+Conflicts:
+ src/network/bridge_driver.c:
+ In one place a later commit was backported prior to this commit,
+ removing a VIR_DEBUG line and some { }. (see upstream commit
+ c102bbd3efc35, which was backported for
+ https://bugzilla.redhat.com/1607929
+
+Signed-off-by: Laine Stump
+Message-Id: <20210415032534.723202-3-laine@redhat.com>
+Reviewed-by: Pavel Hrdina
+---
+ src/network/bridge_driver.c | 16 ++++---
+ src/network/bridge_driver_linux.c | 69 ++++++++++++++++++----------
+ src/network/bridge_driver_nop.c | 3 +-
+ src/network/bridge_driver_platform.h | 2 +-
+ 4 files changed, 58 insertions(+), 32 deletions(-)
+
+diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
+index 5995396f78..b8118067d1 100644
+--- a/src/network/bridge_driver.c
++++ b/src/network/bridge_driver.c
+@@ -271,7 +271,9 @@ static int
+ networkShutdownNetworkExternal(virNetworkObjPtr obj);
+
+ static void
+-networkReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup);
++networkReloadFirewallRules(virNetworkDriverStatePtr driver,
++ bool startup,
++ bool force);
+
+ static void
+ networkRefreshDaemons(virNetworkDriverStatePtr driver);
+@@ -690,7 +692,7 @@ firewalld_dbus_filter_bridge(DBusConnection *connection G_GNUC_UNUSED,
+ }
+
+ if (reload)
+- networkReloadFirewallRules(driver, false);
++ networkReloadFirewallRules(driver, false, true);
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+@@ -791,7 +793,7 @@ networkStateInitialize(bool privileged,
+ virNetworkObjListPrune(network_driver->networks,
+ VIR_CONNECT_LIST_NETWORKS_INACTIVE |
+ VIR_CONNECT_LIST_NETWORKS_TRANSIENT);
+- networkReloadFirewallRules(network_driver, true);
++ networkReloadFirewallRules(network_driver, true, false);
+ networkRefreshDaemons(network_driver);
+
+ if (virDriverShouldAutostart(network_driver->stateDir, &autostart) < 0)
+@@ -861,7 +863,7 @@ networkStateReload(void)
+ network_driver->networkConfigDir,
+ network_driver->networkAutostartDir,
+ network_driver->xmlopt);
+- networkReloadFirewallRules(network_driver, false);
++ networkReloadFirewallRules(network_driver, false, false);
+ networkRefreshDaemons(network_driver);
+ virNetworkObjListForEach(network_driver->networks,
+ networkAutostartConfig,
+@@ -2229,14 +2231,16 @@ networkReloadFirewallRulesHelper(virNetworkObjPtr obj,
+
+
+ static void
+-networkReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup)
++networkReloadFirewallRules(virNetworkDriverStatePtr driver,
++ bool startup,
++ bool force)
+ {
+ VIR_INFO("Reloading iptables rules");
+ /* Ideally we'd not even register the driver when unprivilegd
+ * but until we untangle the virt driver that's not viable */
+ if (!driver->privileged)
+ return;
+- networkPreReloadFirewallRules(driver, startup);
++ networkPreReloadFirewallRules(driver, startup, force);
+ virNetworkObjListForEach(driver->networks,
+ networkReloadFirewallRulesHelper,
+ NULL);
+diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
+index b6b324d1d5..f707bf8e47 100644
+--- a/src/network/bridge_driver_linux.c
++++ b/src/network/bridge_driver_linux.c
+@@ -36,11 +36,14 @@ VIR_LOG_INIT("network.bridge_driver_linux");
+ #define PROC_NET_ROUTE "/proc/net/route"
+
+ static virOnceControl createdOnce;
+-static bool createdChains;
++static bool chainInitDone; /* true iff networkSetupPrivateChains was ever called */
++static bool createdChains; /* true iff networkSetupPrivateChains created chains during most recent call */
+ static virErrorPtr errInitV4;
+ static virErrorPtr errInitV6;
+
+-/* Only call via virOnce */
++/* Usually only called via virOnce, but can also be called directly in
++ * response to firewalld reload (if chainInitDone == true)
++ */
+ static void networkSetupPrivateChains(void)
+ {
+ int rc;
+@@ -82,6 +85,8 @@ static void networkSetupPrivateChains(void)
+ VIR_DEBUG("Global IPv6 chains already exist");
+ }
+ }
++
++ chainInitDone = true;
+ }
+
+
+@@ -111,7 +116,10 @@ networkHasRunningNetworks(virNetworkDriverStatePtr driver)
+ }
+
+
+-void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup)
++void
++networkPreReloadFirewallRules(virNetworkDriverStatePtr driver,
++ bool startup,
++ bool force)
+ {
+ /*
+ * If there are any running networks, we need to
+@@ -130,29 +138,42 @@ void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup
+ * of starting the network though as that makes them
+ * more likely to be seen by a human
+ */
+- if (!networkHasRunningNetworks(driver)) {
+- VIR_DEBUG("Delayed global rule setup as no networks are running");
+- return;
+- }
++ if (chainInitDone && force) {
++ /* The Private chains have already been initialized once
++ * during this run of libvirtd, so 1) we can't do it again via
++ * virOnce(), and 2) we need to re-add the private chains even
++ * if there are currently no running networks, because the
++ * next time a network is started, libvirt will expect that
++ * the chains have already been added. So we call directly
++ * instead of via virOnce().
++ */
++ networkSetupPrivateChains();
+
+- ignore_value(virOnce(&createdOnce, networkSetupPrivateChains));
++ } else {
++ if (!networkHasRunningNetworks(driver)) {
++ VIR_DEBUG("Delayed global rule setup as no networks are running");
++ return;
++ }
+
+- /*
+- * If this is initial startup, and we just created the
+- * top level private chains we either
+- *
+- * - upgraded from old libvirt
+- * - freshly booted from clean state
+- *
+- * In the first case we must delete the old rules from
+- * the built-in chains, instead of our new private chains.
+- * In the second case it doesn't matter, since no existing
+- * rules will be present. Thus we can safely just tell it
+- * to always delete from the builin chain
+- */
+- if (startup && createdChains) {
+- VIR_DEBUG("Requesting cleanup of legacy firewall rules");
+- iptablesSetDeletePrivate(false);
++ ignore_value(virOnce(&createdOnce, networkSetupPrivateChains));
++
++ /*
++ * If this is initial startup, and we just created the
++ * top level private chains we either
++ *
++ * - upgraded from old libvirt
++ * - freshly booted from clean state
++ *
++ * In the first case we must delete the old rules from
++ * the built-in chains, instead of our new private chains.
++ * In the second case it doesn't matter, since no existing
++ * rules will be present. Thus we can safely just tell it
++ * to always delete from the builin chain
++ */
++ if (startup && createdChains) {
++ VIR_DEBUG("Requesting cleanup of legacy firewall rules");
++ iptablesSetDeletePrivate(false);
++ }
+ }
+ }
+
+diff --git a/src/network/bridge_driver_nop.c b/src/network/bridge_driver_nop.c
+index 08d737511f..db89c10023 100644
+--- a/src/network/bridge_driver_nop.c
++++ b/src/network/bridge_driver_nop.c
+@@ -20,7 +20,8 @@
+ #include
+
+ void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver G_GNUC_UNUSED,
+- bool startup G_GNUC_UNUSED)
++ bool startup G_GNUC_UNUSED,
++ bool force G_GNUC_UNUSED)
+ {
+ }
+
+diff --git a/src/network/bridge_driver_platform.h b/src/network/bridge_driver_platform.h
+index 169417a6c0..48ab52c160 100644
+--- a/src/network/bridge_driver_platform.h
++++ b/src/network/bridge_driver_platform.h
+@@ -62,7 +62,7 @@ struct _virNetworkDriverState {
+ typedef struct _virNetworkDriverState virNetworkDriverState;
+ typedef virNetworkDriverState *virNetworkDriverStatePtr;
+
+-void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup);
++void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup, bool force);
+ void networkPostReloadFirewallRules(bool startup);
+
+ int networkCheckRouteCollision(virNetworkDefPtr def);
+--
+2.31.1
+
diff --git a/SOURCES/libvirt-network-make-it-safe-to-call-networkSetupPrivateChains-multiple-times.patch b/SOURCES/libvirt-network-make-it-safe-to-call-networkSetupPrivateChains-multiple-times.patch
new file mode 100644
index 0000000..b07b70d
--- /dev/null
+++ b/SOURCES/libvirt-network-make-it-safe-to-call-networkSetupPrivateChains-multiple-times.patch
@@ -0,0 +1,65 @@
+From 4792bd80c542f7af373bc939492017bd420a3f3b Mon Sep 17 00:00:00 2001
+Message-Id: <4792bd80c542f7af373bc939492017bd420a3f3b@dist-git>
+From: Laine Stump
+Date: Wed, 14 Apr 2021 23:25:33 -0400
+Subject: [PATCH] network: make it safe to call networkSetupPrivateChains()
+ multiple times
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+networkSetupPrivateChains() is currently called only once per run of
+libvirtd, so it can assume that errInitV4 and errInitV6 are empty/null
+when it is called. In preparation for potentially calling this
+function multiple times during one run, this patch moves the reset of
+errInitV[46] to the top of the function, to assure no memory is
+leaked.
+
+Signed-off-by: Laine Stump
+Reviewed-by: Daniel P. Berrangé
+(cherry picked from commit de110f110fb917a31b9f33ad8e4b3c1d3284766a)
+
+https://bugzilla.redhat.com/1942805
+
+Message-Id: <20210415032534.723202-2-laine@redhat.com>
+Reviewed-by: Pavel Hrdina
+---
+ src/network/bridge_driver_linux.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
+index 9de8e93c60..b6b324d1d5 100644
+--- a/src/network/bridge_driver_linux.c
++++ b/src/network/bridge_driver_linux.c
+@@ -48,6 +48,10 @@ static void networkSetupPrivateChains(void)
+ VIR_DEBUG("Setting up global firewall chains");
+
+ createdChains = false;
++ virFreeError(errInitV4);
++ errInitV4 = NULL;
++ virFreeError(errInitV6);
++ errInitV6 = NULL;
+
+ rc = iptablesSetupPrivateChains(VIR_FIREWALL_LAYER_IPV4);
+ if (rc < 0) {
+@@ -56,8 +60,6 @@ static void networkSetupPrivateChains(void)
+ errInitV4 = virSaveLastError();
+ virResetLastError();
+ } else {
+- virFreeError(errInitV4);
+- errInitV4 = NULL;
+ if (rc) {
+ VIR_DEBUG("Created global IPv4 chains");
+ createdChains = true;
+@@ -73,8 +75,6 @@ static void networkSetupPrivateChains(void)
+ errInitV6 = virSaveLastError();
+ virResetLastError();
+ } else {
+- virFreeError(errInitV6);
+- errInitV6 = NULL;
+ if (rc) {
+ VIR_DEBUG("Created global IPv6 chains");
+ createdChains = true;
+--
+2.31.1
+
diff --git a/SOURCES/libvirt-qemu-Add-virtio-related-options-to-vsock.patch b/SOURCES/libvirt-qemu-Add-virtio-related-options-to-vsock.patch
new file mode 100644
index 0000000..4b1eab9
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Add-virtio-related-options-to-vsock.patch
@@ -0,0 +1,312 @@
+From 362d106d8897a3982f5eaed0c4bc0194d6f9ef28 Mon Sep 17 00:00:00 2001
+Message-Id: <362d106d8897a3982f5eaed0c4bc0194d6f9ef28@dist-git>
+From: Boris Fiuczynski
+Date: Fri, 26 Feb 2021 06:43:35 -0500
+Subject: [PATCH] qemu: Add virtio related options to vsock
+
+Add virtio related options iommu, ats and packed as driver element attributes
+to vsock devices. Ex:
+
+
+
+
+
+
+Signed-off-by: Boris Fiuczynski
+Signed-off-by: Michal Privoznik
+Reviewed-by: Michal Privoznik
+(cherry picked from commit bd112c9e0f7523b90bf1362cf60deea7db05a32b)
+
+Resolves: https://bugzilla.redhat.com/1931548
+
+Note: since the virtio option packed is not yet available in the code
+version it will also not be available with this backported patch.
+
+Conflicts: docs/formatdomain.rst:
+ converted changes into docs/formatdomain.html.in
+ src/conf/domain_conf.c:
+ resolved conflicts by moving the code into the correct methods
+ src/conf/domain_validate.c:
+ does not exist downstream. moved code to src/conf/domain_conf.c
+ src/qemu/qemu_validate.c:
+ does not exist downstream. can be neglected
+
+Message-Id: <20210226114335.100390-2-bfiuczyn@redhat.com>
+Reviewed-by: Pavel Hrdina
+---
+ docs/formatdomain.html.in | 5 ++-
+ docs/schemas/domaincommon.rng | 5 +++
+ src/conf/domain_conf.c | 27 ++++++++++++++
+ src/conf/domain_conf.h | 1 +
+ src/qemu/qemu_command.c | 4 ++
+ .../vhost-vsock-ccw-iommu.s390x-latest.args | 37 +++++++++++++++++++
+ .../vhost-vsock-ccw-iommu.xml | 37 +++++++++++++++++++
+ tests/qemuxml2argvtest.c | 1 +
+ .../vhost-vsock-ccw-iommu.s390x-latest.xml | 1 +
+ tests/qemuxml2xmltest.c | 2 +
+ 10 files changed, 119 insertions(+), 1 deletion(-)
+ create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args
+ create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml
+ create mode 120000 tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml
+
+diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
+index bec753e37f..127dd13cc0 100644
+--- a/docs/formatdomain.html.in
++++ b/docs/formatdomain.html.in
+@@ -9240,7 +9240,10 @@ qemu-kvm -net nic,model=? /dev/null
+ element specifies the CID assigned to the guest. If the attribute
+ auto is set to yes, libvirt
+ will assign a free CID automatically on domain startup.
+- Since 4.4.0
++ Since 4.4.0
++ The optional driver element allows to specify virtio options, see
++ Virtio-specific options for more details.
++ Since 7.1.0
+
+