mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
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:
parent
a62dca833e
commit
20664ec779
@ -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,
|
||||
|
@ -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 { \
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,6 +174,7 @@ virDomainCapsCPUModelsAdd;
|
||||
virDomainCapsCPUModelsAddSteal;
|
||||
virDomainCapsCPUModelsCopy;
|
||||
virDomainCapsCPUModelsFilter;
|
||||
virDomainCapsCPUModelsGet;
|
||||
virDomainCapsCPUModelsNew;
|
||||
virDomainCapsCPUUsableTypeFromString;
|
||||
virDomainCapsCPUUsableTypeToString;
|
||||
|
Loading…
Reference in New Issue
Block a user