mirror of https://gitee.com/openkylin/libvirt.git
cpu: Add x86FeatureInData
The function checks CPUID data for a given feature. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
ff559b80d0
commit
dc4542dea5
|
@ -767,6 +767,27 @@ x86FeatureFindInternal(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
x86FeatureInData(const char *name,
|
||||||
|
const virCPUx86Data *data,
|
||||||
|
virCPUx86MapPtr map)
|
||||||
|
{
|
||||||
|
virCPUx86FeaturePtr feature;
|
||||||
|
|
||||||
|
if (!(feature = x86FeatureFind(map, name)) &&
|
||||||
|
!(feature = x86FeatureFindInternal(name))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("unknown CPU feature %s"), name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x86DataIsSubset(data, &feature->data))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
x86FeatureIsMigratable(const char *name,
|
x86FeatureIsMigratable(const char *name,
|
||||||
void *cpu_map)
|
void *cpu_map)
|
||||||
|
@ -2526,15 +2547,12 @@ x86UpdateCustom(virCPUDefPtr guest,
|
||||||
|
|
||||||
for (i = 0; i < guest->nfeatures; i++) {
|
for (i = 0; i < guest->nfeatures; i++) {
|
||||||
if (guest->features[i].policy == VIR_CPU_FEATURE_OPTIONAL) {
|
if (guest->features[i].policy == VIR_CPU_FEATURE_OPTIONAL) {
|
||||||
virCPUx86FeaturePtr feature;
|
int supported = x86FeatureInData(guest->features[i].name,
|
||||||
if (!(feature = x86FeatureFind(map, guest->features[i].name))) {
|
&host_model->data, map);
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Unknown CPU feature %s"),
|
|
||||||
guest->features[i].name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x86DataIsSubset(&host_model->data, &feature->data))
|
if (supported < 0)
|
||||||
|
goto cleanup;
|
||||||
|
else if (supported)
|
||||||
guest->features[i].policy = VIR_CPU_FEATURE_REQUIRE;
|
guest->features[i].policy = VIR_CPU_FEATURE_REQUIRE;
|
||||||
else
|
else
|
||||||
guest->features[i].policy = VIR_CPU_FEATURE_DISABLE;
|
guest->features[i].policy = VIR_CPU_FEATURE_DISABLE;
|
||||||
|
@ -2646,23 +2664,11 @@ x86HasFeature(const virCPUData *data,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
virCPUx86MapPtr map;
|
virCPUx86MapPtr map;
|
||||||
virCPUx86FeaturePtr feature;
|
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(map = virCPUx86GetMap()))
|
if (!(map = virCPUx86GetMap()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(feature = x86FeatureFind(map, name)) &&
|
return x86FeatureInData(name, &data->data.x86, map);
|
||||||
!(feature = x86FeatureFindInternal(name))) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("unknown CPU feature %s"), name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = x86DataIsSubset(&data->data.x86, &feature->data) ? 1 : 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue