mirror of https://gitee.com/openkylin/libvirt.git
cpu: Introduce virCPUCheckForbiddenFeatures
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com
This commit is contained in:
parent
1e1db67836
commit
a839fcbe62
|
@ -690,6 +690,43 @@ virCPUCheckFeature(virArch arch,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* virCPUCheckForbiddenFeatures:
|
||||
*
|
||||
* @guest: CPU definition
|
||||
* @host: CPU definition
|
||||
*
|
||||
* Checks that @host enables no feature explicitly disabled by @guest.
|
||||
*
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
int
|
||||
virCPUCheckForbiddenFeatures(virCPUDefPtr guest, const virCPUDef *host)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < guest->nfeatures; ++i) {
|
||||
virCPUFeatureDefPtr feature;
|
||||
|
||||
if (guest->features[i].policy != VIR_CPU_FEATURE_FORBID)
|
||||
continue;
|
||||
|
||||
feature = virCPUDefFindFeature(host, guest->features[i].name);
|
||||
if (!feature)
|
||||
continue;
|
||||
|
||||
if (feature->policy == VIR_CPU_FEATURE_DISABLE)
|
||||
continue;
|
||||
|
||||
virReportError(VIR_ERR_CPU_INCOMPATIBLE,
|
||||
_("Host CPU provides forbidden feature '%s'"),
|
||||
guest->features[i].name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virCPUDataCheckFeature:
|
||||
*
|
||||
|
|
|
@ -228,6 +228,12 @@ virCPUCheckFeature(virArch arch,
|
|||
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||
|
||||
|
||||
int
|
||||
virCPUCheckForbiddenFeatures(virCPUDefPtr guest,
|
||||
const virCPUDef *host)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
|
||||
int
|
||||
virCPUDataCheckFeature(const virCPUData *data,
|
||||
const char *feature)
|
||||
|
|
|
@ -1421,6 +1421,7 @@ cpuEncode;
|
|||
virCPUArchIsSupported;
|
||||
virCPUBaseline;
|
||||
virCPUCheckFeature;
|
||||
virCPUCheckForbiddenFeatures;
|
||||
virCPUCompare;
|
||||
virCPUCompareXML;
|
||||
virCPUConvertLegacy;
|
||||
|
|
Loading…
Reference in New Issue