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