[PATCH 2/3] virutil: introduce helper to set memory limits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using this macro will ensure that the value stored in domain def will
never be greater than VIR_DOMAIN_MEMORY_PARAM_UNLIMITED.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/virutil.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/util/virutil.h b/src/util/virutil.h
index d1173c1..003eee6 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -98,6 +98,10 @@ const char *virEnumToString(const char *const*types,
     const char *name ## TypeToString(int type);         \
     int name ## TypeFromString(const char*type);
 
+# define VIR_SET_MEMORY_LIMIT(limit, value)                             \
+    limit = (value) < VIR_DOMAIN_MEMORY_PARAM_UNLIMITED ? (value) :     \
+        VIR_DOMAIN_MEMORY_PARAM_UNLIMITED
+
 /* No-op workarounds for functionality missing in mingw.  */
 # ifndef HAVE_GETUID
 static inline int getuid(void)
-- 
2.0.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]