ia64/xen-unstable

changeset 7715:5066d2aa2fb0

More fixes for save/restore; use configured memory for generating sxp.

Signed-off-by: Steven Hand <steven@xensource.com>
author smh22@firebug.cl.cam.ac.uk
date Wed Nov 09 13:59:53 2005 +0100 (2005-11-09)
parents 1e6147db55cf
children 356c175366a1
files tools/libxc/xc_linux_restore.c tools/libxc/xg_save_restore.h tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/libxc/xc_linux_restore.c	Wed Nov 09 12:39:38 2005 +0100
     1.2 +++ b/tools/libxc/xc_linux_restore.c	Wed Nov 09 13:59:53 2005 +0100
     1.3 @@ -516,8 +516,8 @@ int xc_linux_restore(int xc_handle, int 
     1.4                  /* shouldn't happen - continue optimistically */
     1.5                  continue; 
     1.6  
     1.7 -            pfntab[i] = p2m[pfn];
     1.8 -            p2m[pfn]  = 0x80000001;  // not in pmap
     1.9 +            pfntab[i] = p2m[pfn];   
    1.10 +            p2m[pfn]  = INVALID_P2M_ENTRY; // not in pseudo-physical map 
    1.11          }
    1.12          
    1.13          if (count > 0) {
     2.1 --- a/tools/libxc/xg_save_restore.h	Wed Nov 09 12:39:38 2005 +0100
     2.2 +++ b/tools/libxc/xg_save_restore.h	Wed Nov 09 13:59:53 2005 +0100
     2.3 @@ -118,6 +118,7 @@ static int get_platform_info(int xc_hand
     2.4  /* Returns TRUE if the PFN is currently mapped */
     2.5  #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
     2.6  
     2.7 +#define INVALID_P2M_ENTRY   (~0UL) 
     2.8  
     2.9  
    2.10  
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Nov 09 12:39:38 2005 +0100
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Nov 09 13:59:53 2005 +0100
     3.3 @@ -113,6 +113,8 @@ ROUNDTRIPPING_CONFIG_ENTRIES = [
     3.4          ('vcpus',        int),
     3.5          ('vcpu_avail',   int),
     3.6          ('cpu_weight',   float),
     3.7 +        ('memory',       int),
     3.8 +        ('maxmem',       int),
     3.9          ('bootloader',   str),
    3.10          ('on_poweroff',  str),
    3.11          ('on_reboot',    str),
    3.12 @@ -256,10 +258,6 @@ def parseConfig(config):
    3.13      for e in ROUNDTRIPPING_CONFIG_ENTRIES:
    3.14          result[e[0]] = get_cfg(e[0], e[1])
    3.15  
    3.16 -    result['memory']    = get_cfg('memory',    int)
    3.17 -    result['mem_kb']    = get_cfg('mem_kb',    int)
    3.18 -    result['maxmem']    = get_cfg('maxmem',    int)
    3.19 -    result['maxmem_kb'] = get_cfg('maxmem_kb', int)
    3.20      result['cpu']       = get_cfg('cpu',       int)
    3.21      result['image']     = get_cfg('image')
    3.22  
    3.23 @@ -394,6 +392,7 @@ class XendDomainInfo:
    3.24                    ("on_reboot",    str),
    3.25                    ("on_crash",     str),
    3.26                    ("image",        str),
    3.27 +                  ("memory",       int),
    3.28                    ("vcpus",        int),
    3.29                    ("vcpu_avail",   int),
    3.30                    ("start_time", float))
    3.31 @@ -432,6 +431,9 @@ class XendDomainInfo:
    3.32              self.info['vcpus'] = int(self.info['vcpus'])
    3.33  
    3.34              defaultInfo('vcpu_avail',   lambda: (1 << self.info['vcpus']) - 1)
    3.35 +
    3.36 +            defaultInfo('memory',       lambda: 0)
    3.37 +            defaultInfo('maxmem',       lambda: 0)
    3.38              defaultInfo('bootloader',   lambda: None)
    3.39              defaultInfo('backend',      lambda: [])
    3.40              defaultInfo('device',       lambda: [])
    3.41 @@ -442,66 +444,12 @@ class XendDomainInfo:
    3.42              if isinstance(self.info['image'], str):
    3.43                  self.info['image'] = sxp.from_string(self.info['image'])
    3.44  
    3.45 -            # Internally, we keep only maxmem_KiB, and not maxmem or maxmem_kb
    3.46 -            # (which come from outside, and are in MiB and KiB respectively).
    3.47 -            # This means that any maxmem or maxmem_kb settings here have come
    3.48 -            # from outside, and maxmem_KiB must be updated to reflect them.
    3.49 -            # If we have both maxmem and maxmem_kb and these are not
    3.50 -            # consistent, then this is an error, as we've no way to tell which
    3.51 -            # one takes precedence.
    3.52 -
    3.53 -            # Exactly the same thing applies to memory_KiB, memory, and
    3.54 -            # mem_kb.
    3.55 -
    3.56 -            def discard_negatives(name):
    3.57 -                if self.infoIsSet(name) and self.info[name] < 0:
    3.58 -                    del self.info[name]
    3.59 +            if self.info['memory'] == 0:
    3.60 +                if self.infoIsSet('mem_kb'):
    3.61 +                    self.info['memory'] = (self.info['mem_kb'] + 1023) / 1024
    3.62  
    3.63 -            def valid_KiB_(mb_name, kb_name):
    3.64 -                discard_negatives(kb_name)
    3.65 -                discard_negatives(mb_name)
    3.66 -                
    3.67 -                if self.infoIsSet(kb_name):
    3.68 -                    if self.infoIsSet(mb_name):
    3.69 -                        mb = self.info[mb_name]
    3.70 -                        kb = self.info[kb_name]
    3.71 -                        if mb * 1024 == kb:
    3.72 -                            return kb
    3.73 -                        else:
    3.74 -                            raise VmError(
    3.75 -                                'Inconsistent %s / %s settings: %s / %s' %
    3.76 -                                (mb_name, kb_name, mb, kb))
    3.77 -                    else:
    3.78 -                        return self.info[kb_name]
    3.79 -                elif self.infoIsSet(mb_name):
    3.80 -                    return self.info[mb_name] * 1024
    3.81 -                else:
    3.82 -                    return None
    3.83 -
    3.84 -            def valid_KiB(mb_name, kb_name):
    3.85 -                result = valid_KiB_(mb_name, kb_name)
    3.86 -                if result is None or result < 0:
    3.87 -                    raise VmError('Invalid %s / %s: %s' %
    3.88 -                                  (mb_name, kb_name, result))
    3.89 -                else:
    3.90 -                    return result
    3.91 -
    3.92 -            def delIf(name):
    3.93 -                if name in self.info:
    3.94 -                    del self.info[name]
    3.95 -
    3.96 -            self.info['memory_KiB'] = valid_KiB('memory', 'mem_kb')
    3.97 -            delIf('memory')
    3.98 -            delIf('mem_kb')
    3.99 -            self.info['maxmem_KiB'] = valid_KiB_('maxmem', 'maxmem_kb')
   3.100 -            delIf('maxmem')
   3.101 -            delIf('maxmem_kb')
   3.102 -
   3.103 -            if not self.info['maxmem_KiB']:
   3.104 -                self.info['maxmem_KiB'] = 1 << 30
   3.105 -
   3.106 -            if self.info['maxmem_KiB'] > self.info['memory_KiB']:
   3.107 -                self.info['maxmem_KiB'] = self.info['memory_KiB']
   3.108 +            if self.info['maxmem'] < self.info['memory']:
   3.109 +                self.info['maxmem'] = self.info['memory']
   3.110  
   3.111              for (n, c) in self.info['device']:
   3.112                  if not n or not c or n not in controllerClasses:
   3.113 @@ -576,17 +524,14 @@ class XendDomainInfo:
   3.114  
   3.115      def storeVmDetails(self):
   3.116          to_store = {
   3.117 -            'uuid':               self.info['uuid'],
   3.118 -
   3.119 -            # XXX
   3.120 -            'memory/target':      str(self.info['memory_KiB'])
   3.121 +            'uuid':               self.info['uuid']
   3.122              }
   3.123  
   3.124          if self.infoIsSet('image'):
   3.125              to_store['image'] = sxp.to_string(self.info['image'])
   3.126  
   3.127 -        for k in ['name', 'ssidref', 'on_poweroff', 'on_reboot', 'on_crash',
   3.128 -                  'vcpus', 'vcpu_avail']:
   3.129 +        for k in ['name', 'ssidref', 'memory', 'maxmem', 'on_poweroff',
   3.130 +                  'on_reboot', 'on_crash', 'vcpus', 'vcpu_avail']:
   3.131              if self.infoIsSet(k):
   3.132                  to_store[k] = str(self.info[k])
   3.133  
   3.134 @@ -601,7 +546,7 @@ class XendDomainInfo:
   3.135              'vm':                 self.vmpath,
   3.136              'name':               self.info['name'],
   3.137              'console/limit':      str(xroot.get_console_limit() * 1024),
   3.138 -            'memory/target':      str(self.info['memory_KiB'])
   3.139 +            'memory/target':      str(self.info['memory'] * 1024)
   3.140              }
   3.141  
   3.142          def f(n, v):
   3.143 @@ -682,8 +627,8 @@ class XendDomainInfo:
   3.144          return self.info['ssidref']
   3.145  
   3.146      def getMemoryTarget(self):
   3.147 -        """Get this domain's target memory size, in KiB."""
   3.148 -        return self.info['memory_KiB']
   3.149 +        """Get this domain's target memory size, in KB."""
   3.150 +        return self.info['memory'] * 1024
   3.151  
   3.152  
   3.153      def refreshShutdown(self, xeninfo = None):
   3.154 @@ -831,10 +776,9 @@ class XendDomainInfo:
   3.155          """Set the memory target of this domain.
   3.156          @param target In MiB.
   3.157          """
   3.158 -        # Internally we use KiB, but the command interface uses MiB.
   3.159 -        t = target << 10
   3.160 -        self.info['memory_KiB'] = t
   3.161 -        self.storeDom("memory/target", t)
   3.162 +        self.info['memory'] = target
   3.163 +        self.storeVm("memory", target)
   3.164 +        self.storeDom("memory/target", target << 10)
   3.165  
   3.166  
   3.167      def update(self, info = None):
   3.168 @@ -883,7 +827,7 @@ class XendDomainInfo:
   3.169          s = "<domain"
   3.170          s += " id=" + str(self.domid)
   3.171          s += " name=" + self.info['name']
   3.172 -        s += " memory=" + str(self.info['memory_KiB'] / 1024)
   3.173 +        s += " memory=" + str(self.info['memory'])
   3.174          s += " ssidref=" + str(self.info['ssidref'])
   3.175          s += ">"
   3.176          return s
   3.177 @@ -937,15 +881,12 @@ class XendDomainInfo:
   3.178  
   3.179      def sxpr(self):
   3.180          sxpr = ['domain',
   3.181 -                ['domid',   self.domid],
   3.182 -                ['memory',  self.info['memory_KiB'] / 1024]]
   3.183 +                ['domid',   self.domid]]
   3.184  
   3.185          for e in ROUNDTRIPPING_CONFIG_ENTRIES:
   3.186              if self.infoIsSet(e[0]):
   3.187                  sxpr.append([e[0], self.info[e[0]]])
   3.188          
   3.189 -        sxpr.append(['maxmem', self.info['maxmem_KiB'] / 1024])
   3.190 -
   3.191          if self.infoIsSet('image'):
   3.192              sxpr.append(['image', self.info['image']])
   3.193  
   3.194 @@ -1086,9 +1027,8 @@ class XendDomainInfo:
   3.195  
   3.196  
   3.197      def initDomain(self):
   3.198 -        log.debug('XendDomainInfo.initDomain: %s %s %s',
   3.199 +        log.debug('XendDomainInfo.initDomain: %s %s',
   3.200                    self.domid,
   3.201 -                  self.info['memory_KiB'],
   3.202                    self.info['cpu_weight'])
   3.203  
   3.204          if not self.infoIsSet('image'):
   3.205 @@ -1103,7 +1043,7 @@ class XendDomainInfo:
   3.206  
   3.207          xc.domain_setcpuweight(self.domid, self.info['cpu_weight'])
   3.208  
   3.209 -        m = self.image.getDomainMemory(self.info['memory_KiB'])
   3.210 +        m = self.image.getDomainMemory(self.info['memory'] * 1024)
   3.211          xc.domain_setmaxmem(self.domid, maxmem_kb = m)
   3.212          xc.domain_memory_increase_reservation(self.domid, m, 0, 0)
   3.213