]> xenbits.xensource.com Git - xen.git/commitdiff
Split the meaning of "dom0-min-mem = 0" to a new option.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 7 Apr 2008 14:01:26 +0000 (15:01 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 7 Apr 2008 14:01:26 +0000 (15:01 +0100)
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>
tools/examples/xend-config-xenapi.sxp
tools/examples/xend-config.sxp
tools/python/xen/xend/XendOptions.py
tools/python/xen/xend/balloon.py

index d80083ad7f0289d902cd5df9f4001abff7a4c9ad..dcbddf959e1d89e9b68eb68a1b1575a509d0bc47 100644 (file)
 #(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)
index 22c0b24a25535a4c88a570b9441c86af8a8eb170..f3ee4f3a15f6247977e4171899b97e42ab9202f8 100644 (file)
 #(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)
index 8895c5bb8c0fc6087a6555de2e1b0a28b368c6b0..cae9a4d19a1db03ccf382de57af8e1b59d2eb721 100644 (file)
@@ -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)
 
index 168070ea13c88b6e09d13dc48b4bb7eebc8ca8d4..5f2c41915ee5719c56659a74d148685c582b54e6 100644 (file)
@@ -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(