|
|
4372d3 |
From 3d7a4041d31e403dc9e762b34f7faf36f7f20a28 Mon Sep 17 00:00:00 2001
|
|
|
4372d3 |
Message-Id: <3d7a4041d31e403dc9e762b34f7faf36f7f20a28@dist-git>
|
|
|
abb18f |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
abb18f |
Date: Tue, 26 Apr 2022 15:02:51 +0200
|
|
|
abb18f |
Subject: [PATCH] cpu_x86: Refactor feature list comparison in
|
|
|
abb18f |
x86DecodeUseCandidate
|
|
|
abb18f |
|
|
|
abb18f |
It will become more complicated and so it deserves to be separated into
|
|
|
abb18f |
a new function.
|
|
|
abb18f |
|
|
|
abb18f |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
abb18f |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
abb18f |
(cherry picked from commit 1d6ca40ac23c039abc4392b668f256d0eda33280)
|
|
|
abb18f |
|
|
|
4372d3 |
https://bugzilla.redhat.com/show_bug.cgi?id=1851227
|
|
|
abb18f |
|
|
|
abb18f |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
abb18f |
---
|
|
|
abb18f |
src/cpu/cpu_x86.c | 31 ++++++++++++++++++++++---------
|
|
|
abb18f |
1 file changed, 22 insertions(+), 9 deletions(-)
|
|
|
abb18f |
|
|
|
abb18f |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
abb18f |
index f007487824..81c2441b8b 100644
|
|
|
abb18f |
--- a/src/cpu/cpu_x86.c
|
|
|
abb18f |
+++ b/src/cpu/cpu_x86.c
|
|
|
abb18f |
@@ -1970,6 +1970,27 @@ virCPUx86Compare(virCPUDef *host,
|
|
|
abb18f |
}
|
|
|
abb18f |
|
|
|
abb18f |
|
|
|
abb18f |
+static int
|
|
|
abb18f |
+virCPUx86CompareCandidateFeatureList(virCPUDef *cpuCurrent,
|
|
|
abb18f |
+ virCPUDef *cpuCandidate)
|
|
|
abb18f |
+{
|
|
|
abb18f |
+ size_t current = cpuCurrent->nfeatures;
|
|
|
abb18f |
+ size_t candidate = cpuCandidate->nfeatures;
|
|
|
abb18f |
+
|
|
|
abb18f |
+ if (candidate < current) {
|
|
|
abb18f |
+ VIR_DEBUG("%s is better than %s: %zu < %zu",
|
|
|
abb18f |
+ cpuCandidate->model, cpuCurrent->model,
|
|
|
abb18f |
+ candidate, current);
|
|
|
abb18f |
+ return 1;
|
|
|
abb18f |
+ }
|
|
|
abb18f |
+
|
|
|
abb18f |
+ VIR_DEBUG("%s is not better than %s: %zu >= %zu",
|
|
|
abb18f |
+ cpuCandidate->model, cpuCurrent->model,
|
|
|
abb18f |
+ candidate, current);
|
|
|
abb18f |
+ return 0;
|
|
|
abb18f |
+}
|
|
|
abb18f |
+
|
|
|
abb18f |
+
|
|
|
abb18f |
/*
|
|
|
abb18f |
* Checks whether a candidate model is a better fit for the CPU data than the
|
|
|
abb18f |
* current model.
|
|
|
abb18f |
@@ -2038,15 +2059,7 @@ x86DecodeUseCandidate(virCPUx86Model *current,
|
|
|
abb18f |
}
|
|
|
abb18f |
}
|
|
|
abb18f |
|
|
|
abb18f |
- if (cpuCurrent->nfeatures > cpuCandidate->nfeatures) {
|
|
|
abb18f |
- VIR_DEBUG("%s results in shorter feature list than %s",
|
|
|
abb18f |
- cpuCandidate->model, cpuCurrent->model);
|
|
|
abb18f |
- return 1;
|
|
|
abb18f |
- }
|
|
|
abb18f |
-
|
|
|
abb18f |
- VIR_DEBUG("%s does not result in shorter feature list than %s",
|
|
|
abb18f |
- cpuCandidate->model, cpuCurrent->model);
|
|
|
abb18f |
- return 0;
|
|
|
abb18f |
+ return virCPUx86CompareCandidateFeatureList(cpuCurrent, cpuCandidate);
|
|
|
abb18f |
}
|
|
|
abb18f |
|
|
|
abb18f |
|
|
|
abb18f |
--
|
|
|
abb18f |
2.35.1
|
|
|
abb18f |
|