[Kimchi-devel] [PATCH v2] Fix template default memory in hosts with few memory
Rodrigo Trujillo
rodrigo.trujillo at linux.vnet.ibm.com
Mon Sep 28 14:02:59 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..aaa12b1 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 _get_arch() == 'x86':
+ return 1024 if mem > 1024 else mem
+ else:
+ # In PPC some guests does not boot with less than 2G of memory. However
+ # we can do nothing if host has less than that amount.
+ return 2048 if mem > 2048 else mem
def _get_tmpl_defaults():
--
2.1.0
More information about the Kimchi-devel
mailing list