From b2de33e2a704ac56a3767169c05ce4edddd3b21d Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 13 Oct 2010 12:26:22 +0200 Subject: [PATCH] cpu: Use vendor in baseline CPU only if all hosts use it When only some host CPUs given to cpuBaseline contain 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 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index a329b1cf3b..425a8ebe13 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -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: -- GitLab