mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
cpu_x86: Introduce virCPUx86FeatureFilter*MSR
This functions may be used as a virCPUDefFeatureFilter callbacks for virCPUDefCheckFeatures, virCPUDefFilerFeatures, and similar functions to select (virCPUx86FeatureFilterSelectMSR) or drop (virCPUx86FeatureFilterDropMSR) features reported via MSR. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b8e086a570
commit
bcfed7f1c8
@ -3362,6 +3362,63 @@ virCPUx86DataAddFeature(virCPUDataPtr cpuData,
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
virCPUx86FeatureIsMSR(const char *name)
|
||||
{
|
||||
virCPUx86FeaturePtr feature;
|
||||
virCPUx86DataIterator iter;
|
||||
virCPUx86DataItemPtr item;
|
||||
virCPUx86MapPtr map;
|
||||
|
||||
if (!(map = virCPUx86GetMap()))
|
||||
return false;
|
||||
|
||||
if (!(feature = x86FeatureFind(map, name)) &&
|
||||
!(feature = x86FeatureFindInternal(name)))
|
||||
return false;
|
||||
|
||||
virCPUx86DataIteratorInit(&iter, &feature->data);
|
||||
while ((item = virCPUx86DataNext(&iter))) {
|
||||
if (item->type == VIR_CPU_X86_DATA_MSR)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virCPUx86FeatureFilterSelectMSR:
|
||||
*
|
||||
* This is a callback for functions filtering features in virCPUDef. The result
|
||||
* will contain only MSR features.
|
||||
*
|
||||
* Returns true if @name is an MSR feature, false otherwise.
|
||||
*/
|
||||
bool
|
||||
virCPUx86FeatureFilterSelectMSR(const char *name,
|
||||
void *opaque ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return virCPUx86FeatureIsMSR(name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virCPUx86FeatureFilterDropMSR:
|
||||
*
|
||||
* This is a callback for functions filtering features in virCPUDef. The result
|
||||
* will not contain any MSR feature.
|
||||
*
|
||||
* Returns true if @name is not an MSR feature, false otherwise.
|
||||
*/
|
||||
bool
|
||||
virCPUx86FeatureFilterDropMSR(const char *name,
|
||||
void *opaque ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return !virCPUx86FeatureIsMSR(name);
|
||||
}
|
||||
|
||||
|
||||
struct cpuArchDriver cpuDriverX86 = {
|
||||
.name = "x86",
|
||||
.arch = archs,
|
||||
|
@ -40,3 +40,9 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
|
||||
|
||||
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
||||
const char *vendor);
|
||||
|
||||
bool virCPUx86FeatureFilterSelectMSR(const char *name,
|
||||
void *opaque);
|
||||
|
||||
bool virCPUx86FeatureFilterDropMSR(const char *name,
|
||||
void *opaque);
|
||||
|
@ -1268,7 +1268,8 @@ virCPUx86DataAdd;
|
||||
virCPUx86DataGetSignature;
|
||||
virCPUx86DataSetSignature;
|
||||
virCPUx86DataSetVendor;
|
||||
|
||||
virCPUx86FeatureFilterDropMSR;
|
||||
virCPUx86FeatureFilterSelectMSR;
|
||||
|
||||
# datatypes.h
|
||||
virConnectClass;
|
||||
|
Loading…
Reference in New Issue
Block a user