# HG changeset patch # User Brendan Cully # Date 1259807950 28800 # Node ID 7ae7abac67e9476c0af33b2e074a76cffbf0c432 # Parent aa0b5558564f882903ca1c84948bc2a3619d9f73 Remus: fix shadow memory allocation, broken in 20558:4ed3b9b1de3f This approach is perhaps a little cleaner than directly calling balloon.free. Signed-off-by: Brendan Cully diff --git a/tools/python/xen/remus/vm.py b/tools/python/xen/remus/vm.py --- a/tools/python/xen/remus/vm.py +++ b/tools/python/xen/remus/vm.py @@ -3,9 +3,8 @@ import xmlrpclib from xen.xend.XendClient import server -from xen.xend import sxp -# XXX XendDomain is voodoo to let balloon import succeed -from xen.xend import XendDomain, balloon +from xen.xend import sxp, osdep +from xen.lowlevel.xc import xc import vif import blkdev @@ -150,7 +149,13 @@ # from XendDomainInfo.checkLiveMigrateMemory: # 1MB per vcpu plus 4Kib/Mib of RAM. This is higher than # the minimum that Xen would allocate if no value were given. - needed = vcpus * 1024 + maxmem * 4 - shadow * 1024 + shadowneeded = vcpus * 1024 + maxmem * 4 - shadow * 1024 + physinfo = xc().physinfo() + freemem = int(physinfo['free_memory']) + needed = shadowneeded - freemem if needed > 0: print "Freeing %d kB for shadow mode" % needed - balloon.free(needed, vm.dominfo) + dom0cur = osdep.lookup_balloon_stat('current') + # target is in MB, not KB + target = (dom0cur - needed) / 1024 + server.xend.domain.setMemoryTarget(0, target)