ia64/xen-unstable

changeset 6744:bc5e0fc79696

fix ballooning out logic to handle dying domain freeing memory.

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author vh249@arcadians.cl.cam.ac.uk
date Sat Sep 10 14:43:46 2005 +0000 (2005-09-10)
parents b3b4391a14e5
children 3f2751c6e721
files tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xm/create.py	Sat Sep 10 14:42:39 2005 +0000
     1.2 +++ b/tools/python/xen/xm/create.py	Sat Sep 10 14:43:46 2005 +0000
     1.3 @@ -772,30 +772,33 @@ def balloon_out(dom0_min_mem, opts):
     1.4      """Balloon out memory from dom0 if necessary"""
     1.5      SLACK = 4
     1.6      timeout = 20 # 2s
     1.7 -    ret = 0
     1.8 +    ret = 1
     1.9  
    1.10      xc = xen.lowlevel.xc.new()
    1.11 -    pinfo = xc.physinfo()
    1.12 -    free_mem = pinfo['free_pages'] / 256
    1.13 +    free_mem = xc.physinfo()['free_pages'] / 256
    1.14      domU_need_mem = opts.vals.memory + SLACK 
    1.15  
    1.16 +    # we already have enough free memory, return success
    1.17 +    if free_mem >= domU_need_mem:
    1.18 +        del xc
    1.19 +        return 0
    1.20 +
    1.21      dom0_cur_alloc = get_dom0_alloc()
    1.22      dom0_new_alloc = dom0_cur_alloc - (domU_need_mem - free_mem)
    1.23 -
    1.24 -    if free_mem < domU_need_mem and dom0_new_alloc < dom0_min_mem:
    1.25 -        ret = 1
    1.26 -    if free_mem < domU_need_mem and ret == 0:
    1.27 -
    1.28 -        server.xend_domain_mem_target_set(0, dom0_new_alloc)
    1.29 +    if dom0_new_alloc < dom0_min_mem:
    1.30 +        dom0_new_alloc = dom0_min_mem
    1.31  
    1.32 -        while dom0_cur_alloc > dom0_new_alloc and timeout > 0:
    1.33 -            time.sleep(0.1) # sleep 100ms
    1.34 -            dom0_cur_alloc = get_dom0_alloc()
    1.35 -            timeout -= 1
    1.36 -        
    1.37 -        if dom0_cur_alloc > dom0_new_alloc:
    1.38 -            ret = 1
    1.39 -    
    1.40 +    server.xend_domain_mem_target_set(0, dom0_new_alloc)
    1.41 +
    1.42 +    while timeout > 0:
    1.43 +        time.sleep(0.1) # sleep 100ms
    1.44 +
    1.45 +        free_mem = xc.physinfo()['free_pages'] / 256
    1.46 +        if free_mem >= domU_need_mem:
    1.47 +            ret = 0
    1.48 +            break
    1.49 +        timeout -= 1
    1.50 +
    1.51      del xc
    1.52      return ret
    1.53