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