libvirt/SOURCES/libvirt-cpu_x86-Honor-CPU-models-decode-element.patch
2021-09-10 11:58:15 +00:00

68 lines
2.6 KiB
Diff

From ba2f2a8c39f2e7fe5684d9b84a0a832be482a3ab Mon Sep 17 00:00:00 2001
Message-Id: <ba2f2a8c39f2e7fe5684d9b84a0a832be482a3ab@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:58:57 +0200
Subject: [PATCH] cpu_x86: Honor CPU models' <decode> element
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
(cherry picked from commit 7cd896ef31d33f78d40df918a33fe3867e251509)
https://bugzilla.redhat.com/show_bug.cgi?id=1840008
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <15f1eedf2c0df29a3942b4b28bc4575fa51ca19a.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 7fbb4c9a6c..b4d5c795f7 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2044,10 +2044,23 @@ x86DecodeUseCandidate(virCPUx86ModelPtr current,
virCPUx86ModelPtr candidate,
virCPUDefPtr cpuCandidate,
uint32_t signature,
- const char *preferred,
- bool checkPolicy)
+ const char *preferred)
{
- if (checkPolicy) {
+ if (cpuCandidate->type == VIR_CPU_TYPE_HOST &&
+ !candidate->decodeHost) {
+ VIR_DEBUG("%s is not supposed to be used for host CPU definition",
+ cpuCandidate->model);
+ return 0;
+ }
+
+ if (cpuCandidate->type == VIR_CPU_TYPE_GUEST &&
+ !candidate->decodeGuest) {
+ VIR_DEBUG("%s is not supposed to be used for guest CPU definition",
+ cpuCandidate->model);
+ return 0;
+ }
+
+ if (cpuCandidate->type == VIR_CPU_TYPE_HOST) {
size_t i;
for (i = 0; i < cpuCandidate->nfeatures; i++) {
if (cpuCandidate->features[i].policy == VIR_CPU_FEATURE_DISABLE)
@@ -2209,8 +2222,7 @@ x86Decode(virCPUDefPtr cpu,
if ((rc = x86DecodeUseCandidate(model, cpuModel,
candidate, cpuCandidate,
- signature, preferred,
- cpu->type == VIR_CPU_TYPE_HOST))) {
+ signature, preferred))) {
virCPUDefFree(cpuModel);
cpuModel = cpuCandidate;
model = candidate;
--
2.26.2