ia64/xen-unstable

changeset 17401:6143f5bd32a7

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 <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 07 15:01:26 2008 +0100 (2008-04-07)
parents e8f058b99171
children 146f214a0e63
files tools/examples/xend-config-xenapi.sxp tools/examples/xend-config.sxp tools/python/xen/xend/XendOptions.py tools/python/xen/xend/balloon.py
line diff
     1.1 --- a/tools/examples/xend-config-xenapi.sxp	Sat Apr 05 22:25:30 2008 +0100
     1.2 +++ b/tools/examples/xend-config-xenapi.sxp	Mon Apr 07 15:01:26 2008 +0100
     1.3 @@ -167,11 +167,14 @@
     1.4  #(network-script network-nat)
     1.5  #(vif-script     vif-nat)
     1.6  
     1.7 +# dom0-min-mem is the lowest permissible memory level (in MB) for dom0.
     1.8 +# This is a minimum both for auto-ballooning (as enabled by
     1.9 +# enable-dom0-ballooning below) and for xm mem-set when applied to dom0.
    1.10 +(dom0-min-mem 196)
    1.11  
    1.12 -# Dom0 will balloon out when needed to free memory for domU.
    1.13 -# dom0-min-mem is the lowest memory level (in MB) dom0 will get down to.
    1.14 -# If dom0-min-mem=0, dom0 will never balloon out.
    1.15 -(dom0-min-mem 196)
    1.16 +# Whether to enable auto-ballooning of dom0 to allow domUs to be created.
    1.17 +# If enable-dom0-ballooning = no, dom0 will never balloon out.
    1.18 +(enable-dom0-ballooning yes)
    1.19  
    1.20  # In SMP system, dom0 will use dom0-cpus # of CPUS
    1.21  # If dom0-cpus = 0, dom0 will take all cpus available
     2.1 --- a/tools/examples/xend-config.sxp	Sat Apr 05 22:25:30 2008 +0100
     2.2 +++ b/tools/examples/xend-config.sxp	Mon Apr 07 15:01:26 2008 +0100
     2.3 @@ -165,11 +165,14 @@
     2.4  #(network-script network-nat)
     2.5  #(vif-script     vif-nat)
     2.6  
     2.7 +# dom0-min-mem is the lowest permissible memory level (in MB) for dom0.
     2.8 +# This is a minimum both for auto-ballooning (as enabled by
     2.9 +# enable-dom0-ballooning below) and for xm mem-set when applied to dom0.
    2.10 +(dom0-min-mem 196)
    2.11  
    2.12 -# Dom0 will balloon out when needed to free memory for domU.
    2.13 -# dom0-min-mem is the lowest memory level (in MB) dom0 will get down to.
    2.14 -# If dom0-min-mem=0, dom0 will never balloon out.
    2.15 -(dom0-min-mem 196)
    2.16 +# Whether to enable auto-ballooning of dom0 to allow domUs to be created.
    2.17 +# If enable-dom0-ballooning = no, dom0 will never balloon out.
    2.18 +(enable-dom0-ballooning yes)
    2.19  
    2.20  # In SMP system, dom0 will use dom0-cpus # of CPUS
    2.21  # If dom0-cpus = 0, dom0 will take all cpus available
     3.1 --- a/tools/python/xen/xend/XendOptions.py	Sat Apr 05 22:25:30 2008 +0100
     3.2 +++ b/tools/python/xen/xend/XendOptions.py	Mon Apr 07 15:01:26 2008 +0100
     3.3 @@ -279,6 +279,13 @@ class XendOptions:
     3.4      def get_dom0_min_mem(self):
     3.5          return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default)
     3.6  
     3.7 +    def get_enable_dom0_ballooning(self):
     3.8 +        enable_dom0_ballooning_default = 'yes'
     3.9 +        if self.get_dom0_min_mem() == 0:
    3.10 +            enable_dom0_ballooning_default = 'no'
    3.11 +        return self.get_config_bool('enable-dom0-ballooning',
    3.12 +                                    enable_dom0_ballooning_default)
    3.13 +
    3.14      def get_dom0_vcpus(self):
    3.15          return self.get_config_int('dom0-cpus', self.dom0_vcpus_default)
    3.16  
     4.1 --- a/tools/python/xen/xend/balloon.py	Sat Apr 05 22:25:30 2008 +0100
     4.2 +++ b/tools/python/xen/xend/balloon.py	Mon Apr 07 15:01:26 2008 +0100
     4.3 @@ -81,8 +81,8 @@ def free(need_mem):
     4.4      # needs to balloon.  No matter where we expect the free memory to come
     4.5      # from, we need to wait for it to become available.
     4.6      #
     4.7 -    # We are not allowed to balloon below dom0_min_mem, or if dom0_min_mem
     4.8 -    # is 0, we cannot balloon at all.  Memory can still become available
     4.9 +    # We are not allowed to balloon below dom0_min_mem, or if dom0_ballooning
    4.10 +    # is False, we cannot balloon at all.  Memory can still become available
    4.11      # through a rebooting domain, however.
    4.12      #
    4.13      # Eventually, we time out (presumably because there really isn't enough
    4.14 @@ -100,6 +100,7 @@ def free(need_mem):
    4.15  
    4.16      try:
    4.17          dom0_min_mem = xoptions.get_dom0_min_mem() * 1024
    4.18 +        dom0_ballooning = xoptions.get_enable_dom0_ballooning()
    4.19          dom0_alloc = get_dom0_current_alloc()
    4.20  
    4.21          retries = 0
    4.22 @@ -115,7 +116,7 @@ def free(need_mem):
    4.23          free_mem = physinfo['free_memory']
    4.24          scrub_mem = physinfo['scrub_memory']
    4.25          total_mem = physinfo['total_memory']
    4.26 -        if dom0_min_mem > 0:
    4.27 +        if dom0_ballooning:
    4.28              max_free_mem = total_mem - dom0_min_mem
    4.29          else:
    4.30              max_free_mem = total_mem - dom0_alloc
    4.31 @@ -137,7 +138,7 @@ def free(need_mem):
    4.32                  log.debug("Balloon: %d KiB free; %d to scrub; need %d; retries: %d.",
    4.33                            free_mem, scrub_mem, need_mem, rlimit)
    4.34  
    4.35 -            if dom0_min_mem > 0:
    4.36 +            if dom0_ballooning:
    4.37                  dom0_alloc = get_dom0_current_alloc()
    4.38                  new_alloc = dom0_alloc - (need_mem - free_mem - scrub_mem)
    4.39  
    4.40 @@ -163,10 +164,10 @@ def free(need_mem):
    4.41              last_free = free_mem + scrub_mem
    4.42  
    4.43          # Not enough memory; diagnose the problem.
    4.44 -        if dom0_min_mem == 0:
    4.45 -            raise VmError(('Not enough free memory and dom0_min_mem is 0, so '
    4.46 -                           'I cannot release any more.  I need %d KiB but '
    4.47 -                           'only have %d.') %
    4.48 +        if not dom0_ballooning:
    4.49 +            raise VmError(('Not enough free memory and enable-dom0-ballooning '
    4.50 +                           'is False, so I cannot release any more.  '
    4.51 +                           'I need %d KiB but only have %d.') %
    4.52                            (need_mem, free_mem))
    4.53          elif new_alloc < dom0_min_mem:
    4.54              raise VmError(