From 54cdc383f128d5682852d1d55e091445a433810c Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 7 Apr 2008 15:01:26 +0100 Subject: [PATCH] Split the meaning of "dom0-min-mem = 0" to a new option. I have written a patch to split the current meaning of "dom0-min-mem = 0" to a new option "enable-dom0-ballooning". Signed-off-by: Masaki Kanno Signed-off-by: Keir Fraser --- tools/examples/xend-config-xenapi.sxp | 11 +++++++---- tools/examples/xend-config.sxp | 11 +++++++---- tools/python/xen/xend/XendOptions.py | 7 +++++++ tools/python/xen/xend/balloon.py | 17 +++++++++-------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/tools/examples/xend-config-xenapi.sxp b/tools/examples/xend-config-xenapi.sxp index d80083ad7f..dcbddf959e 100644 --- a/tools/examples/xend-config-xenapi.sxp +++ b/tools/examples/xend-config-xenapi.sxp @@ -167,12 +167,15 @@ #(network-script network-nat) #(vif-script vif-nat) - -# Dom0 will balloon out when needed to free memory for domU. -# dom0-min-mem is the lowest memory level (in MB) dom0 will get down to. -# If dom0-min-mem=0, dom0 will never balloon out. +# dom0-min-mem is the lowest permissible memory level (in MB) for dom0. +# This is a minimum both for auto-ballooning (as enabled by +# enable-dom0-ballooning below) and for xm mem-set when applied to dom0. (dom0-min-mem 196) +# Whether to enable auto-ballooning of dom0 to allow domUs to be created. +# If enable-dom0-ballooning = no, dom0 will never balloon out. +(enable-dom0-ballooning yes) + # In SMP system, dom0 will use dom0-cpus # of CPUS # If dom0-cpus = 0, dom0 will take all cpus available (dom0-cpus 0) diff --git a/tools/examples/xend-config.sxp b/tools/examples/xend-config.sxp index 22c0b24a25..f3ee4f3a15 100644 --- a/tools/examples/xend-config.sxp +++ b/tools/examples/xend-config.sxp @@ -165,12 +165,15 @@ #(network-script network-nat) #(vif-script vif-nat) - -# Dom0 will balloon out when needed to free memory for domU. -# dom0-min-mem is the lowest memory level (in MB) dom0 will get down to. -# If dom0-min-mem=0, dom0 will never balloon out. +# dom0-min-mem is the lowest permissible memory level (in MB) for dom0. +# This is a minimum both for auto-ballooning (as enabled by +# enable-dom0-ballooning below) and for xm mem-set when applied to dom0. (dom0-min-mem 196) +# Whether to enable auto-ballooning of dom0 to allow domUs to be created. +# If enable-dom0-ballooning = no, dom0 will never balloon out. +(enable-dom0-ballooning yes) + # In SMP system, dom0 will use dom0-cpus # of CPUS # If dom0-cpus = 0, dom0 will take all cpus available (dom0-cpus 0) diff --git a/tools/python/xen/xend/XendOptions.py b/tools/python/xen/xend/XendOptions.py index 8895c5bb8c..cae9a4d19a 100644 --- a/tools/python/xen/xend/XendOptions.py +++ b/tools/python/xen/xend/XendOptions.py @@ -279,6 +279,13 @@ class XendOptions: def get_dom0_min_mem(self): return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default) + def get_enable_dom0_ballooning(self): + enable_dom0_ballooning_default = 'yes' + if self.get_dom0_min_mem() == 0: + enable_dom0_ballooning_default = 'no' + return self.get_config_bool('enable-dom0-ballooning', + enable_dom0_ballooning_default) + def get_dom0_vcpus(self): return self.get_config_int('dom0-cpus', self.dom0_vcpus_default) diff --git a/tools/python/xen/xend/balloon.py b/tools/python/xen/xend/balloon.py index 168070ea13..5f2c41915e 100644 --- a/tools/python/xen/xend/balloon.py +++ b/tools/python/xen/xend/balloon.py @@ -81,8 +81,8 @@ def free(need_mem): # needs to balloon. No matter where we expect the free memory to come # from, we need to wait for it to become available. # - # We are not allowed to balloon below dom0_min_mem, or if dom0_min_mem - # is 0, we cannot balloon at all. Memory can still become available + # We are not allowed to balloon below dom0_min_mem, or if dom0_ballooning + # is False, we cannot balloon at all. Memory can still become available # through a rebooting domain, however. # # Eventually, we time out (presumably because there really isn't enough @@ -100,6 +100,7 @@ def free(need_mem): try: dom0_min_mem = xoptions.get_dom0_min_mem() * 1024 + dom0_ballooning = xoptions.get_enable_dom0_ballooning() dom0_alloc = get_dom0_current_alloc() retries = 0 @@ -115,7 +116,7 @@ def free(need_mem): free_mem = physinfo['free_memory'] scrub_mem = physinfo['scrub_memory'] total_mem = physinfo['total_memory'] - if dom0_min_mem > 0: + if dom0_ballooning: max_free_mem = total_mem - dom0_min_mem else: max_free_mem = total_mem - dom0_alloc @@ -137,7 +138,7 @@ def free(need_mem): log.debug("Balloon: %d KiB free; %d to scrub; need %d; retries: %d.", free_mem, scrub_mem, need_mem, rlimit) - if dom0_min_mem > 0: + if dom0_ballooning: dom0_alloc = get_dom0_current_alloc() new_alloc = dom0_alloc - (need_mem - free_mem - scrub_mem) @@ -163,10 +164,10 @@ def free(need_mem): last_free = free_mem + scrub_mem # Not enough memory; diagnose the problem. - if dom0_min_mem == 0: - raise VmError(('Not enough free memory and dom0_min_mem is 0, so ' - 'I cannot release any more. I need %d KiB but ' - 'only have %d.') % + if not dom0_ballooning: + raise VmError(('Not enough free memory and enable-dom0-ballooning ' + 'is False, so I cannot release any more. ' + 'I need %d KiB but only have %d.') % (need_mem, free_mem)) elif new_alloc < dom0_min_mem: raise VmError( -- 2.39.5