1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-13 08:58:33 +03:00

cpu_x86: Implement virCPUValidateFeatures

The function checks whether all CPU features used in a CPU definition
are specified in cpu_map.xml.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2017-09-14 16:14:40 +02:00
parent 20edbad776
commit ea9741f600

View File

@ -2925,6 +2925,28 @@ virCPUx86CopyMigratable(virCPUDefPtr cpu)
}
static int
virCPUx86ValidateFeatures(virCPUDefPtr cpu)
{
virCPUx86MapPtr map;
size_t i;
if (!(map = virCPUx86GetMap()))
return -1;
for (i = 0; i < cpu->nfeatures; i++) {
if (!x86FeatureFind(map, cpu->features[i].name)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown CPU feature: %s"),
cpu->features[i].name);
return -1;
}
}
return 0;
}
int
virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
const virCPUx86CPUID *cpuid)
@ -3001,4 +3023,5 @@ struct cpuArchDriver cpuDriverX86 = {
.translate = virCPUx86Translate,
.expandFeatures = virCPUx86ExpandFeatures,
.copyMigratable = virCPUx86CopyMigratable,
.validateFeatures = virCPUx86ValidateFeatures,
};