Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > ebe084c140192657f9094e135a84202c > files > 74

libvirt-0.8.2-29.el5.src.rpm

From 9c9ea6d2e75f9e015ff19239db56434f064ffb60 Mon Sep 17 00:00:00 2001
Message-Id: <9c9ea6d2e75f9e015ff19239db56434f064ffb60.1284409900.git.jdenemar@redhat.com>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Mon, 12 Jul 2010 14:41:36 +0200
Subject: [PATCH] cpuCompare: Fix comparison of two host CPUs

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=630615

When a CPU to be compared with host CPU describes a host CPU instead of
a guest CPU, the result is incorrect. This is because instead of
treating additional features in host CPU description as required, they
were treated as if they were mentioned with all possible policies at the
same time.

(backported from commit ac3daf0899cced61faeeed3c6e14806d9e846174)
---
 src/cpu/cpu_x86.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 30a2db6..fdd5323 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -630,8 +630,7 @@ x86ModelFromCPU(const virCPUDefPtr cpu,
     struct x86_model *model = NULL;
     int i;
 
-    if (cpu->type == VIR_CPU_TYPE_HOST
-        || policy == VIR_CPU_FEATURE_REQUIRE) {
+    if (policy == VIR_CPU_FEATURE_REQUIRE) {
         if ((model = x86ModelFind(map, cpu->model)) == NULL) {
             virCPUReportError(VIR_ERR_INTERNAL_ERROR,
                     _("Unknown CPU model %s"), cpu->model);
@@ -643,6 +642,8 @@ x86ModelFromCPU(const virCPUDefPtr cpu,
     }
     else if (VIR_ALLOC(model) < 0)
         goto no_memory;
+    else if (cpu->type == VIR_CPU_TYPE_HOST)
+        return model;
 
     for (i = 0; i < cpu->nfeatures; i++) {
         const struct x86_feature *feature;
@@ -946,7 +947,7 @@ x86Compute(virCPUDefPtr host,
     }
 
     if (!(map = x86LoadMap()) ||
-        !(host_model = x86ModelFromCPU(host, map, 0)) ||
+        !(host_model = x86ModelFromCPU(host, map, VIR_CPU_FEATURE_REQUIRE)) ||
         !(cpu_force = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_FORCE)) ||
         !(cpu_require = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_REQUIRE)) ||
         !(cpu_optional = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_OPTIONAL)) ||
@@ -1342,7 +1343,7 @@ x86Baseline(virCPUDefPtr *cpus,
     if (!(map = x86LoadMap()))
         goto error;
 
-    if (!(base_model = x86ModelFromCPU(cpus[0], map, 0)))
+    if (!(base_model = x86ModelFromCPU(cpus[0], map, VIR_CPU_FEATURE_REQUIRE)))
         goto error;
 
     if (VIR_ALLOC(cpu) < 0 ||
@@ -1353,7 +1354,7 @@ x86Baseline(virCPUDefPtr *cpus,
 
     for (i = 1; i < ncpus; i++) {
         struct x86_model *model;
-        if (!(model = x86ModelFromCPU(cpus[i], map, 0)))
+        if (!(model = x86ModelFromCPU(cpus[i], map, VIR_CPU_FEATURE_REQUIRE)))
             goto error;
 
         x86ModelIntersect(base_model, model);
@@ -1395,7 +1396,7 @@ x86Update(virCPUDefPtr guest,
     union cpuData *data = NULL;
 
     if (!(map = x86LoadMap()) ||
-        !(host_model = x86ModelFromCPU(host, map, 0)))
+        !(host_model = x86ModelFromCPU(host, map, VIR_CPU_FEATURE_REQUIRE)))
         goto cleanup;
 
     for (i = 0; i < guest->nfeatures; i++) {
-- 
1.7.2.2