mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: Introduce virCPUDefCheckFeatures
This API can be used to check whether a CPU definition contains features matching a given filter. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
bf6c2830b6
commit
4e6f58b8d5
@ -930,6 +930,39 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virCPUDefCheckFeatures:
|
||||||
|
*
|
||||||
|
* Check CPU features for which @filter reports true and store them in a NULL
|
||||||
|
* terminated list returned via @features.
|
||||||
|
*
|
||||||
|
* Returns the number of features matching @filter or -1 on error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virCPUDefCheckFeatures(virCPUDefPtr cpu,
|
||||||
|
virCPUDefFeatureFilter filter,
|
||||||
|
void *opaque,
|
||||||
|
char ***features)
|
||||||
|
{
|
||||||
|
VIR_AUTOSTRINGLIST list = NULL;
|
||||||
|
size_t n = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
*features = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < cpu->nfeatures; i++) {
|
||||||
|
if (filter(cpu->features[i].name, opaque)) {
|
||||||
|
if (virStringListAdd(&list, cpu->features[i].name) < 0)
|
||||||
|
return -1;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_STEAL_PTR(*features, list);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virCPUDefIsEqual(virCPUDefPtr src,
|
virCPUDefIsEqual(virCPUDefPtr src,
|
||||||
virCPUDefPtr dst,
|
virCPUDefPtr dst,
|
||||||
|
@ -224,6 +224,12 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
|
|||||||
virCPUDefFeatureFilter filter,
|
virCPUDefFeatureFilter filter,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
|
int
|
||||||
|
virCPUDefCheckFeatures(virCPUDefPtr cpu,
|
||||||
|
virCPUDefFeatureFilter filter,
|
||||||
|
void *opaque,
|
||||||
|
char ***features);
|
||||||
|
|
||||||
virCPUDefPtr *
|
virCPUDefPtr *
|
||||||
virCPUDefListParse(const char **xmlCPUs,
|
virCPUDefListParse(const char **xmlCPUs,
|
||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
|
@ -73,6 +73,7 @@ virCapabilitiesSetNetPrefix;
|
|||||||
virCPUCacheModeTypeFromString;
|
virCPUCacheModeTypeFromString;
|
||||||
virCPUCacheModeTypeToString;
|
virCPUCacheModeTypeToString;
|
||||||
virCPUDefAddFeature;
|
virCPUDefAddFeature;
|
||||||
|
virCPUDefCheckFeatures;
|
||||||
virCPUDefCopy;
|
virCPUDefCopy;
|
||||||
virCPUDefCopyModel;
|
virCPUDefCopyModel;
|
||||||
virCPUDefCopyModelFilter;
|
virCPUDefCopyModelFilter;
|
||||||
|
Loading…
Reference in New Issue
Block a user