mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
cpu: Introduce virCPUValidateFeatures
This new API may be used to check whether all features used in a CPU definition are valid (e.g., libvirt knows their name, their policy is supported, etc.). Leaving this API unimplemented in an arch subdriver means libvirt does not restrict CPU features usable on the associated architectures. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
2ba32a86dd
commit
6ef9c202f2
@ -1076,3 +1076,32 @@ virCPUCopyMigratable(virArch arch,
|
|||||||
else
|
else
|
||||||
return virCPUDefCopy(cpu);
|
return virCPUDefCopy(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virCPUValidateFeatures:
|
||||||
|
*
|
||||||
|
* @arch: CPU architecture
|
||||||
|
* @cpu: CPU definition to be checked
|
||||||
|
*
|
||||||
|
* Checks whether all CPU features specified in @cpu are valid.
|
||||||
|
*
|
||||||
|
* Returns 0 on success (all features are valid), -1 on error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virCPUValidateFeatures(virArch arch,
|
||||||
|
virCPUDefPtr cpu)
|
||||||
|
{
|
||||||
|
struct cpuArchDriver *driver;
|
||||||
|
|
||||||
|
VIR_DEBUG("arch=%s, cpu=%p, nfeatures=%zu",
|
||||||
|
virArchToString(arch), cpu, cpu->nfeatures);
|
||||||
|
|
||||||
|
if (!(driver = cpuGetSubDriver(arch)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (driver->validateFeatures)
|
||||||
|
return driver->validateFeatures(cpu);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -121,6 +121,9 @@ typedef int
|
|||||||
typedef virCPUDefPtr
|
typedef virCPUDefPtr
|
||||||
(*virCPUArchCopyMigratable)(virCPUDefPtr cpu);
|
(*virCPUArchCopyMigratable)(virCPUDefPtr cpu);
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(*virCPUArchValidateFeatures)(virCPUDefPtr cpu);
|
||||||
|
|
||||||
struct cpuArchDriver {
|
struct cpuArchDriver {
|
||||||
const char *name;
|
const char *name;
|
||||||
const virArch *arch;
|
const virArch *arch;
|
||||||
@ -142,6 +145,7 @@ struct cpuArchDriver {
|
|||||||
virCPUArchConvertLegacy convertLegacy;
|
virCPUArchConvertLegacy convertLegacy;
|
||||||
virCPUArchExpandFeatures expandFeatures;
|
virCPUArchExpandFeatures expandFeatures;
|
||||||
virCPUArchCopyMigratable copyMigratable;
|
virCPUArchCopyMigratable copyMigratable;
|
||||||
|
virCPUArchValidateFeatures validateFeatures;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -258,6 +262,11 @@ virCPUDefPtr
|
|||||||
virCPUCopyMigratable(virArch arch,
|
virCPUCopyMigratable(virArch arch,
|
||||||
virCPUDefPtr cpu);
|
virCPUDefPtr cpu);
|
||||||
|
|
||||||
|
int
|
||||||
|
virCPUValidateFeatures(virArch arch,
|
||||||
|
virCPUDefPtr cpu)
|
||||||
|
ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
/* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
|
/* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and
|
||||||
* have no real-life usage
|
* have no real-life usage
|
||||||
*/
|
*/
|
||||||
|
@ -1097,6 +1097,7 @@ virCPUProbeHost;
|
|||||||
virCPUTranslate;
|
virCPUTranslate;
|
||||||
virCPUUpdate;
|
virCPUUpdate;
|
||||||
virCPUUpdateLive;
|
virCPUUpdateLive;
|
||||||
|
virCPUValidateFeatures;
|
||||||
|
|
||||||
|
|
||||||
# cpu/cpu_x86.h
|
# cpu/cpu_x86.h
|
||||||
|
Loading…
Reference in New Issue
Block a user