]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Consolidate signature match in x86DecodeUseCandidate
authorJiri Denemark <jdenemar@redhat.com>
Tue, 26 Apr 2022 09:58:07 +0000 (11:58 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 6 May 2022 15:33:46 +0000 (17:33 +0200)
Checking the signature in two different places makes no sense since the
code in between can only mark the candidate as the best option so far,
which is what the second signature match does as well.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/cpu/cpu_x86.c

index a5eac7601cad66ffd34123cd2688617a736931bd..80019ebd703d1c4b712cb86047f727e9f18e9fc1 100644 (file)
@@ -2006,15 +2006,22 @@ x86DecodeUseCandidate(virCPUx86Model *current,
     }
 
     /* Ideally we want to select a model with family/model equal to
-     * family/model of the real CPU. Once we found such model, we only
+     * family/model of the real CPU and once we found such model, we only
      * consider candidates with matching family/model.
      */
-    if (signature &&
-        virCPUx86SignaturesMatch(current->signatures, signature) &&
-        !virCPUx86SignaturesMatch(candidate->signatures, signature)) {
-        VIR_DEBUG("%s differs in signature from matching %s",
-                  cpuCandidate->model, cpuCurrent->model);
-        return 0;
+    if (signature) {
+        if (virCPUx86SignaturesMatch(current->signatures, signature) &&
+            !virCPUx86SignaturesMatch(candidate->signatures, signature)) {
+            VIR_DEBUG("%s differs in signature from matching %s",
+                      cpuCandidate->model, cpuCurrent->model);
+            return 0;
+        }
+
+        if (!virCPUx86SignaturesMatch(current->signatures, signature) &&
+            virCPUx86SignaturesMatch(candidate->signatures, signature)) {
+            VIR_DEBUG("%s provides matching signature", cpuCandidate->model);
+            return 1;
+        }
     }
 
     if (cpuCurrent->nfeatures > cpuCandidate->nfeatures) {
@@ -2023,16 +2030,6 @@ x86DecodeUseCandidate(virCPUx86Model *current,
         return 1;
     }
 
-    /* Prefer a candidate with matching signature even though it would
-     * result in longer list of features.
-     */
-    if (signature &&
-        virCPUx86SignaturesMatch(candidate->signatures, signature) &&
-        !virCPUx86SignaturesMatch(current->signatures, signature)) {
-        VIR_DEBUG("%s provides matching signature", cpuCandidate->model);
-        return 1;
-    }
-
     VIR_DEBUG("%s does not result in shorter feature list than %s",
               cpuCandidate->model, cpuCurrent->model);
     return 0;