提交 ce4c82f1 编写于 作者: J Jiri Denemark

Cleanup x86Compute()

No change in semantics.
上级 71d5686f
......@@ -901,7 +901,7 @@ x86Compute(virCPUDefPtr host,
struct x86_model *guest_model = NULL;
virCPUCompareResult ret;
enum compare_result result;
int i;
unsigned int i;
if (cpu->arch != NULL) {
bool found = false;
......@@ -919,36 +919,15 @@ x86Compute(virCPUDefPtr host,
}
}
if ((map = x86LoadMap()) == NULL)
goto error;
if (!(host_model = x86ModelFromCPU(host, map, 0)))
goto error;
if (!(cpu_force = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_FORCE)))
goto error;
if (!(cpu_require = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_REQUIRE)))
goto error;
if (!(cpu_optional = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_OPTIONAL)))
goto error;
if (!(cpu_disable = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_DISABLE)))
goto error;
if (!(cpu_forbid = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_FORBID)))
if (!(map = x86LoadMap()) ||
!(host_model = x86ModelFromCPU(host, map, 0)) ||
!(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)) ||
!(cpu_disable = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_DISABLE)) ||
!(cpu_forbid = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_FORBID)))
goto error;
x86ModelSubtract(cpu_require, cpu_disable);
if ((diff = x86ModelCopy(host_model)) == NULL)
goto no_memory;
x86ModelSubtract(diff, cpu_require);
x86ModelSubtract(diff, cpu_optional);
x86ModelSubtract(diff, cpu_force);
for (i = 0; i < cpu_forbid->ncpuid; i++) {
const struct cpuX86cpuid *cpuid1;
const struct cpuX86cpuid *cpuid2;
......@@ -966,6 +945,7 @@ x86Compute(virCPUDefPtr host,
}
}
x86ModelSubtract(cpu_require, cpu_disable);
result = x86ModelCompare(host_model, cpu_require);
if (result == SUBSET || result == UNRELATED) {
VIR_DEBUG0("Host CPU does not provide all required features");
......@@ -975,6 +955,14 @@ x86Compute(virCPUDefPtr host,
ret = VIR_CPU_COMPARE_IDENTICAL;
if ((diff = x86ModelCopy(host_model)) == NULL)
goto no_memory;
x86ModelSubtract(diff, cpu_optional);
x86ModelSubtract(diff, cpu_require);
x86ModelSubtract(diff, cpu_disable);
x86ModelSubtract(diff, cpu_force);
for (i = 0; i < host_model->ncpuid; i++) {
if (!x86cpuidMatch(host_model->cpuid + i, &cpuid_zero)) {
ret = VIR_CPU_COMPARE_SUPERSET;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册