yeahuh / rpms / qemu-kvm

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