ia64/xen-unstable

changeset 11442:8013b84df1ac

[XEND] balloon enough memory to enable shadow mode before live migration.a
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <tim.deegan@xensource.com>
date Fri Sep 08 18:55:53 2006 +0100 (2006-09-08)
parents 1de184deaa9c
children 655281bca306
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Wed Sep 06 13:16:02 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Sep 08 18:55:53 2006 +0100
     1.3 @@ -420,6 +420,10 @@ class XendDomain:
     1.4          """ The following call may raise a XendError exception """
     1.5          dominfo.testMigrateDevices(True, dst)
     1.6  
     1.7 +        if live:
     1.8 +            """ Make sure there's memory free for enabling shadow mode """
     1.9 +            dominfo.checkLiveMigrateMemory()
    1.10 +
    1.11          if port == 0:
    1.12              port = xroot.get_xend_relocation_port()
    1.13          try:
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Sep 06 13:16:02 2006 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Sep 08 18:55:53 2006 +0100
     2.3 @@ -49,6 +49,7 @@ from xen.xend.xenstore.xstransact import
     2.4  from xen.xend.xenstore.xsutil import GetDomainPath, IntroduceDomain
     2.5  from xen.xend.xenstore.xswatch import xswatch
     2.6  
     2.7 +from xen.xend import arch
     2.8  
     2.9  """Shutdown code for poweroff."""
    2.10  DOMAIN_POWEROFF = 0
    2.11 @@ -1503,6 +1504,19 @@ class XendDomainInfo:
    2.12  
    2.13      ## public:
    2.14  
    2.15 +    def checkLiveMigrateMemory(self):
    2.16 +        """ Make sure there's enough memory to migrate this domain """
    2.17 +        overhead_kb = 0
    2.18 +        if arch.type == "x86":
    2.19 +            # 1MB per vcpu plus 4Kib/Mib of RAM.  This is higher than 
    2.20 +            # the minimum that Xen would allocate if no value were given.
    2.21 +            overhead_kb = self.info['vcpus'] * 1024 + self.info['maxmem'] * 4
    2.22 +            overhead_kb = ((overhead_kb + 1023) / 1024) * 1024
    2.23 +            # The domain might already have some shadow memory
    2.24 +            overhead_kb -= xc.shadow_mem_control(self.domid) * 1024
    2.25 +        if overhead_kb > 0:
    2.26 +            balloon.free(overhead_kb)
    2.27 +
    2.28      def testMigrateDevices(self, network, dst):
    2.29          """ Notify all device about intention of migration
    2.30          @raise: XendError for a device that cannot be migrated