]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virutil: introduce helper functions for memory limits
authorPavel Hrdina <phrdina@redhat.com>
Wed, 4 Mar 2015 14:08:09 +0000 (15:08 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 6 Mar 2015 10:52:23 +0000 (11:52 +0100)
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@redhat.com>
src/libvirt_private.syms
src/util/virutil.c
src/util/virutil.h

index 3c6fd33a02b68f379c2f6e934851dfa58df85b19..3590bd7371ff0c611bb71c084b1bf3e783b8bcff 100644 (file)
@@ -2270,6 +2270,8 @@ virIsCapableVport;
 virIsDevMapperDevice;
 virIsSUID;
 virManageVport;
+virMemoryLimitIsSet;
+virMemoryLimitTruncate;
 virParseNumber;
 virParseOwnershipIds;
 virParseVersionString;
index 4a95292f5e18f64354217ac456e54e0ebac33b79..599d59c4d3f926ca5d305e59d1ff0f7b2d89796b 100644 (file)
@@ -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;
+}
index d1173c1a110e9d4a8911f0bb13a2886464b82e14..b8f503681e39b43e5b126ae118093b4a4c41845f 100644 (file)
@@ -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__ */