yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
902636
From ccda4494b0ea4b81b6b0c3e539a0bcf7e673c68c Mon Sep 17 00:00:00 2001
902636
From: Eduardo Habkost <ehabkost@redhat.com>
902636
Date: Thu, 5 Dec 2019 21:56:50 +0000
902636
Subject: [PATCH 01/18] i386: Resolve CPU models to v1 by default
902636
902636
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
902636
Message-id: <20191205225650.772600-2-ehabkost@redhat.com>
902636
Patchwork-id: 92907
902636
O-Subject: [RHEL-AV-8.1.1 qemu-kvm PATCH 1/1] i386: Resolve CPU models to v1 by default
902636
Bugzilla: 1787291 1779078 1779078
902636
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
902636
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
902636
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
902636
902636
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1779078
902636
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=25187823
902636
Upstream: submitted, Message-Id: <20191205223339.764534-1-ehabkost@redhat.com>
902636
902636
When using `query-cpu-definitions` using `-machine none`,
902636
QEMU is resolving all CPU models to their latest versions.  The
902636
actual CPU model version being used by another machine type (e.g.
902636
`pc-q35-4.0`) might be different.
902636
902636
In theory, this was OK because the correct CPU model
902636
version is returned when using the correct `-machine` argument.
902636
902636
Except that in practice, this breaks libvirt expectations:
902636
libvirt always use `-machine none` when checking if a CPU model
902636
is runnable, because runnability is not expected to be affected
902636
when the machine type is changed.
902636
902636
For example, when running on a Haswell host without TSX,
902636
Haswell-v4 is runnable, but Haswell-v1 is not.  On those hosts,
902636
`query-cpu-definitions` says Haswell is runnable if using
902636
`-machine none`, but Haswell is actually not runnable using any
902636
of the `pc-*` machine types (because they resolve Haswell to
902636
Haswell-v1).  In other words, we're breaking the "runnability
902636
guarantee" we promised to not break for a few releases (see
902636
qemu-deprecated.texi).
902636
902636
To address this issue, change the default CPU model version to v1
902636
on all machine types, so we make `query-cpu-definitions` output
902636
when using `-machine none` match the results when using `pc-*`.
902636
This will change in the future (the plan is to always return the
902636
latest CPU model version if using `-machine none`), but only
902636
after giving libvirt the opportunity to adapt.
902636
902636
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1779078
902636
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 qemu-deprecated.texi | 7 +++++++
902636
 target/i386/cpu.c    | 8 +++++++-
902636
 2 files changed, 14 insertions(+), 1 deletion(-)
902636
902636
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
902636
index 4b4b742..534ebe9 100644
902636
--- a/qemu-deprecated.texi
902636
+++ b/qemu-deprecated.texi
902636
@@ -374,6 +374,13 @@ guarantees must resolve the CPU model aliases using te
902636
 ``alias-of'' field returned by the ``query-cpu-definitions'' QMP
902636
 command.
902636
 
902636
+While those guarantees are kept, the return value of
902636
+``query-cpu-definitions'' will have existing CPU model aliases
902636
+point to a version that doesn't break runnability guarantees
902636
+(specifically, version 1 of those CPU models).  In future QEMU
902636
+versions, aliases will point to newer CPU model versions
902636
+depending on the machine type, so management software must
902636
+resolve CPU model aliases before starting a virtual machine.
902636
 
902636
 @node Recently removed features
902636
 @appendix Recently removed features
902636
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
902636
index 6dce6f2..863192c 100644
902636
--- a/target/i386/cpu.c
902636
+++ b/target/i386/cpu.c
902636
@@ -3926,7 +3926,13 @@ static PropValue tcg_default_props[] = {
902636
 };
902636
 
902636
 
902636
-X86CPUVersion default_cpu_version = CPU_VERSION_LATEST;
902636
+/*
902636
+ * We resolve CPU model aliases using -v1 when using "-machine
902636
+ * none", but this is just for compatibility while libvirt isn't
902636
+ * adapted to resolve CPU model versions before creating VMs.
902636
+ * See "Runnability guarantee of CPU models" at * qemu-deprecated.texi.
902636
+ */
902636
+X86CPUVersion default_cpu_version = 1;
902636
 
902636
 void x86_cpu_set_default_version(X86CPUVersion version)
902636
 {
902636
-- 
902636
1.8.3.1
902636