thebeanogamer / rpms / qemu-kvm

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