The first one is to truncate the memory limit to VIR_DOMAIN_MEMORY_PARAM_UNLIMITED if the value is greater and the second one is to decide whether the memory limit is set or not, unlimited means that it's not set. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/libvirt_private.syms | 2 ++ src/util/virutil.c | 24 ++++++++++++++++++++++++ src/util/virutil.h | 3 +++ 3 files changed, 29 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c810cf7..66d2333 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2269,6 +2269,8 @@ virIsCapableVport; virIsDevMapperDevice; virIsSUID; virManageVport; +virMemoryLimitIsSet; +virMemoryLimitTruncate; virParseNumber; virParseOwnershipIds; virParseVersionString; diff --git a/src/util/virutil.c b/src/util/virutil.c index 4a95292..599d59c 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -2598,3 +2598,27 @@ long virGetSystemPageSizeKB(void) return val; return val / 1024; } + +/** + * virMemoryLimitTruncate + * + * Return truncated memory limit to VIR_DOMAIN_MEMORY_PARAM_UNLIMITED as maximum + * which means that the limit is not set => unlimited. + */ +unsigned long long +virMemoryLimitTruncate(unsigned long long value) +{ + return value < VIR_DOMAIN_MEMORY_PARAM_UNLIMITED ? value : + VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; +} + +/** + * virMemoryLimitIsSet + * + * Returns true if the limit is set and false for unlimited value. + */ +bool +virMemoryLimitIsSet(unsigned long long value) +{ + return value < VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; +} diff --git a/src/util/virutil.h b/src/util/virutil.h index d1173c1..b8f5036 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -247,4 +247,7 @@ unsigned int virGetListenFDs(void); long virGetSystemPageSize(void); long virGetSystemPageSizeKB(void); +unsigned long long virMemoryLimitTruncate(unsigned long long value); +bool virMemoryLimitIsSet(unsigned long long value); + #endif /* __VIR_UTIL_H__ */ -- 2.0.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list