cpu: Use vendor in baseline CPU only if all hosts use it

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.
This commit is contained in:
Jiri Denemark 2010-10-13 12:26:22 +02:00
parent ac7afbeb9e
commit b2de33e2a7
1 changed files with 12 additions and 4 deletions

View File

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