mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
Remus: fix shadow memory allocation, broken by 20558:4ed3b9b1de3f
This approach is perhaps a little cleaner than directly calling balloon.free. Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
This commit is contained in:
1 parent
40e9da38fd
commit
ba4d310958
1 file changed
+10
-5
@@ -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 @@ def getshadowmem(vm):
|
||||
# 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)
|
||||