]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu: Use vendor in baseline CPU only if all hosts use it
authorJiri Denemark <jdenemar@redhat.com>
Wed, 13 Oct 2010 10:26:22 +0000 (12:26 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 14 Oct 2010 07:36:54 +0000 (09:36 +0200)
When only some host CPUs given to cpuBaseline contain <vendor> element,
baseline CPU should not contain it. Otherwise the result would not be
compatible with the host CPUs without vendor. CPU vendors are still
taken into account when computing baseline CPU, it's just removed from
the result.

src/cpu/cpu_x86.c

index a329b1cf3b949096bdf723b6c3939ebbf311e4ae..425a8ebe136ddcdf1430c170bee1e21ff08625cf 100644 (file)
@@ -1621,6 +1621,7 @@ x86Baseline(virCPUDefPtr *cpus,
     unsigned int i;
     const struct x86_vendor *vendor = NULL;
     struct x86_model *model = NULL;
+    bool outputVendor = true;
 
     if (!(map = x86LoadMap()))
         goto error;
@@ -1634,8 +1635,9 @@ x86Baseline(virCPUDefPtr *cpus,
     cpu->type = VIR_CPU_TYPE_GUEST;
     cpu->match = VIR_CPU_MATCH_EXACT;
 
-    if (cpus[0]->vendor &&
-        !(vendor = x86VendorFind(map, cpus[0]->vendor))) {
+    if (!cpus[0]->vendor)
+        outputVendor = false;
+    else if (!(vendor = x86VendorFind(map, cpus[0]->vendor))) {
         virCPUReportError(VIR_ERR_OPERATION_FAILED,
                 _("Unknown CPU vendor %s"), cpus[0]->vendor);
         goto error;
@@ -1657,8 +1659,11 @@ x86Baseline(virCPUDefPtr *cpus,
 
         if (cpus[i]->vendor)
             vn = cpus[i]->vendor;
-        else if (model->vendor)
-            vn = model->vendor->name;
+        else {
+            outputVendor = false;
+            if (model->vendor)
+                vn = model->vendor->name;
+        }
 
         if (vn) {
             if (!vendor) {
@@ -1694,6 +1699,9 @@ x86Baseline(virCPUDefPtr *cpus,
     if (x86Decode(cpu, data, models, nmodels, NULL) < 0)
         goto error;
 
+    if (!outputVendor)
+        VIR_FREE(cpu->vendor);
+
     VIR_FREE(cpu->arch);
 
 cleanup: