domain_capabilities: Introduce VIR_DOMAIN_CAPS_ENUM_IS_SET

This is a convenient macro for querying whether particular domain
caps enum value is set or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Michal Privoznik 2020-11-17 10:23:33 +01:00
parent 3fba30fc82
commit 4f8677cee2
2 changed files with 3 additions and 1 deletions

View File

@ -287,7 +287,7 @@ virDomainCapsEnumFormat(virBufferPtr buf,
for (i = 0; i < sizeof(capsEnum->values) * CHAR_BIT; i++) {
const char *val;
if (!(capsEnum->values & (1 << i)))
if (!VIR_DOMAIN_CAPS_ENUM_IS_SET(*capsEnum, i))
continue;
if ((val = (valToStr)(i)))

View File

@ -214,6 +214,8 @@ virDomainCapsCPUModelPtr
virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels,
const char *name);
#define VIR_DOMAIN_CAPS_ENUM_IS_SET(capsEnum, value) \
((capsEnum).values & (1 << value))
#define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...) \
do { \