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