Skip to contentSkip to conversation

Give back memory to dom0 after a failed balloon attempt

PATCH New [email protected] 1 participant 1 message Jul 19, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Give back memory to dom0 after a failed balloon attempt

# HG changeset patch
# User [email protected]
# Date 1184846208 25200
# Node ID 5bc01e2fd31dd47234b93a736626931224ec7045 # Parent 8005fc9f56507a58f3ebc2324385331f7a1b7fe1 Give back memory to dom0 after a failed balloon attempt.

tools/python/xen/xend/balloon.py +6 -2
@@ -94,7 +94,9 @@ def free(need_mem):
     # track the last used value so that we don't trigger too many watches.
 
     xoptions = XendOptions.instance()
+    dom0 = XendDomain.instance().privilegedDomain()
     xc = xen.lowlevel.xc.xc()
+    dom0_start_alloc_mb = get_dom0_current_alloc() / 1024
 
     try:
         dom0_min_mem = xoptions.get_dom0_min_mem() * 1024
@@ -133,7 +135,6 @@ def free(need_mem):
                         new_alloc_mb = new_alloc / 1024  # Round down
                         log.debug("Balloon: setting dom0 target to %d MiB.",
                                   new_alloc_mb)
-                        dom0 = XendDomain.instance().privilegedDomain()
                         dom0.setMemoryTarget(new_alloc_mb)
                         last_new_alloc = new_alloc
                 # Continue to retry, waiting for ballooning or scrubbing.
@@ -158,7 +159,10 @@ def free(need_mem):
                 (need_mem, dom0_min_mem, dom0_min_mem,
                  free_mem + scrub_mem + dom0_alloc - dom0_min_mem))
         else:
-            raise VmError('The privileged domain did not balloon!')
+            dom0.setMemoryTarget(dom0_start_alloc_mb)
+            raise VmError(
+                ('Not enough memory is available, and dom0 cannot'
+                 ' be shrunk any further'))
 
     finally:
         del xc