libvirt/SOURCES/libvirt-qemu-avoid-launching-non-x86-guests-with-APIC-EOI-setting.patch
2021-10-08 13:11:20 +00:00

81 lines
3.3 KiB
Diff

From a809e7c5200c4089153768a047f85add0205c4bc Mon Sep 17 00:00:00 2001
Message-Id: <a809e7c5200c4089153768a047f85add0205c4bc@dist-git>
From: Daniel Henrique Barboza <danielhb413@gmail.com>
Date: Mon, 30 Mar 2020 17:18:27 -0400
Subject: [PATCH] qemu: avoid launching non-x86 guests with APIC-EOI setting
The "<apic/>" feature, although it's available only for x86 guests,
can be declared in the domain XML of other archs without errors.
But setting its 'eoi' attribute will break QEMU. For "<apic eoi='on'/>",
in a ppc64 guest:
qemu-kvm: Expected key=value format, found +kvm_pv_eoi
A similar error happens with eoi='off'.
One can argue that it's better to simply forbid launching non-x86
guests with "<apic/>" declared in the XML - it is a feature that
the architecture doesn't support and this would make it clearer
about it. This is sensible, but there are non-x86 guests that are
running with "<apic/>" declared in the domain (and A LOT of guests
running with "<acpi/>" for that matter, probably reminiscent of x86
templates that were reused for other archs) that will stop working if we
go this route.
A more subtle approach is to detect if the 'eoi' element is being set
for non-x86 guests and warn the user about it with a better error
message than the one QEMU provides. This is the new error message
when any value is set for the 'eoi' element in a ppc64 XML:
error: unsupported configuration: The 'eoi' attribute of the 'apic'
feature is not supported for architecture 'ppc64' or machine type
'pseries'.
https://bugzilla.redhat.com/show_bug.cgi?id=1236440
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit dbda73ff27cf185fb5db498cc4db281b2d76778d)
https://bugzilla.redhat.com/show_bug.cgi?id=1829729
Signed-off-by: Daniel Henrique Barboza <dbarboza@redhat.com>
Message-Id: <20200330211827.951474-2-dbarboza@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
---
src/qemu/qemu_domain.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bb28716ff0..8f746cdf13 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5279,8 +5279,23 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
}
break;
- case VIR_DOMAIN_FEATURE_ACPI:
case VIR_DOMAIN_FEATURE_APIC:
+ /* The kvm_pv_eoi feature is x86-only. */
+ if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
+ def->apic_eoi != VIR_TRISTATE_SWITCH_ABSENT &&
+ !ARCH_IS_X86(def->os.arch)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("The 'eoi' attribute of the '%s' feature "
+ "is not supported for architecture '%s' or "
+ "machine type '%s'"),
+ featureName,
+ virArchToString(def->os.arch),
+ def->os.machine);
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_FEATURE_ACPI:
case VIR_DOMAIN_FEATURE_PAE:
case VIR_DOMAIN_FEATURE_HAP:
case VIR_DOMAIN_FEATURE_VIRIDIAN:
--
2.26.2