conf: cpu: Introduce virCPUDefListFeatures

The function returns a list of explicitly mentioned features in the CPU
definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jiri Denemark 2024-03-11 15:37:32 +01:00
parent 909564c365
commit 577c4ca414
3 changed files with 28 additions and 0 deletions

View File

@ -982,6 +982,30 @@ virCPUDefFindFeature(const virCPUDef *def,
}
/**
* virCPUDefListExplicitFeatures:
* @def: CPU definition
*
* Provides a list of feature names explicitly mentioned in the CPU definition
* regardless of the policy. The caller is responsible for freeing the list.
*
* Returns a NULL-terminated list of feature names.
*/
char **
virCPUDefListExplicitFeatures(const virCPUDef *def)
{
char **list;
size_t i;
list = g_new0(char *, def->nfeatures + 1);
for (i = 0; i < def->nfeatures; i++)
list[i] = g_strdup(def->features[i].name);
return list;
}
int
virCPUDefFilterFeatures(virCPUDef *cpu,
virCPUDefFeatureFilter filter,

View File

@ -270,6 +270,9 @@ virCPUDefCheckFeatures(virCPUDef *cpu,
void *opaque,
char ***features);
char **
virCPUDefListExplicitFeatures(const virCPUDef *def);
virCPUDef **
virCPUDefListParse(const char **xmlCPUs,
unsigned int ncpus,

View File

@ -111,6 +111,7 @@ virCPUDefFree;
virCPUDefFreeFeatures;
virCPUDefFreeModel;
virCPUDefIsEqual;
virCPUDefListExplicitFeatures;
virCPUDefListFree;
virCPUDefListParse;
virCPUDefNew;