conf: Introduce virDomainCapsCPUModelsGet

This internal API can be used to find a specific CPU model in
virDomainCapsCPUModels list.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Jiri Denemark 2017-10-13 17:37:34 +02:00
parent a62dca833e
commit 20664ec779
4 changed files with 24 additions and 7 deletions

View File

@ -259,6 +259,24 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
}
virDomainCapsCPUModelPtr
virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels,
const char *name)
{
size_t i;
if (!cpuModels)
return NULL;
for (i = 0; i < cpuModels->nmodels; i++) {
if (STREQ(cpuModels->models[i].name, name))
return cpuModels->models + i;
}
return NULL;
}
int
virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
const char *capsEnumName,

View File

@ -179,6 +179,10 @@ int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
ssize_t nameLen,
virDomainCapsCPUUsable usable,
char **blockers);
virDomainCapsCPUModelPtr
virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels,
const char *name);
# define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...) \
do { \

View File

@ -829,16 +829,10 @@ bool
virCPUModelIsAllowed(const char *model,
virDomainCapsCPUModelsPtr models)
{
size_t i;
if (!models)
return true;
for (i = 0; i < models->nmodels; i++) {
if (STREQ(models->models[i].name, model))
return true;
}
return false;
return !!virDomainCapsCPUModelsGet(models, model);
}

View File

@ -174,6 +174,7 @@ virDomainCapsCPUModelsAdd;
virDomainCapsCPUModelsAddSteal;
virDomainCapsCPUModelsCopy;
virDomainCapsCPUModelsFilter;
virDomainCapsCPUModelsGet;
virDomainCapsCPUModelsNew;
virDomainCapsCPUUsableTypeFromString;
virDomainCapsCPUUsableTypeToString;