[Kimchi-devel] [PATCH] Fix template default memory in hosts with few memory

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Sat Sep 26 07:00:51 UTC 2015


This patch changes the template default memory in hosts that have less
than 1024 MB or less than 2048 in non x86 hosts. If this is the case,
the template memory becomes the host total memory.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/kimchi/osinfo.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
index 6a6af8c..9445f61 100644
--- a/src/kimchi/osinfo.py
+++ b/src/kimchi/osinfo.py
@@ -94,7 +94,16 @@ def _get_arch():
 
 
 def _get_default_template_mem():
-    return 1024 if _get_arch() == 'x86' else 2048
+    if hasattr(psutil, 'virtual_memory'):
+        mem = psutil.virtual_memory().total >> 10 >> 10
+    else:
+        mem = psutil.TOTAL_PHYMEM >> 10 >> 10
+    if mem < 2048 and _get_arch() != 'x86':
+        return mem
+    elif mem < 1024:
+        return mem
+    else:
+        return 1024 if _get_arch() == 'x86' else 2048
 
 
 def _get_tmpl_defaults():
-- 
2.1.0




More information about the Kimchi-devel mailing list