ia64/xen-unstable

changeset 15989:69879c7bf4b5

[xend,xenapi] Fix handling of scheduler params

When creating domains that specify scheduler parameters with XenAPI,
the specified parameters are not used when starting the domain. This
patch collapses cpu_weight and cpu_cap in XendConfig into the
vcpus_params dictionary. The patch has been tested using xm and
XenAPI on config with and without scheduler parameters.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Keir Fraser <keir@xensource.com>
date Wed Sep 26 14:39:56 2007 +0100 (2007-09-26)
parents 80277ff19c9c
children d4511c625a50
files tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Wed Sep 26 14:14:16 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Wed Sep 26 14:39:56 2007 +0100
     1.3 @@ -178,8 +178,6 @@ LEGACY_UNSUPPORTED_BY_XENAPI_CFG = [
     1.4      # roundtripped (dynamic, unmodified)
     1.5      'shadow_memory',
     1.6      'vcpu_avail',
     1.7 -    'cpu_weight',
     1.8 -    'cpu_cap',
     1.9      'features',
    1.10      # read/write
    1.11      'on_xend_start',
    1.12 @@ -203,8 +201,6 @@ LEGACY_CFG_TYPES = {
    1.13      'shadow_memory': int,
    1.14      'maxmem':        int,
    1.15      'start_time':    float,
    1.16 -    'cpu_cap':       int,
    1.17 -    'cpu_weight':    int,
    1.18      'cpu_time':      float,
    1.19      'features':      str,
    1.20      'localtime':     int,
    1.21 @@ -330,8 +326,6 @@ class XendConfig(dict):
    1.22              'on_xend_start': 'ignore',
    1.23              'on_xend_stop': 'ignore',
    1.24              'cpus': [],
    1.25 -            'cpu_weight': 256,
    1.26 -            'cpu_cap': 0,
    1.27              'VCPUs_max': 1,
    1.28              'VCPUs_live': 1,
    1.29              'VCPUs_at_startup': 1,
    1.30 @@ -496,6 +490,14 @@ class XendConfig(dict):
    1.31          if sxp.child_value(sxp_cfg, "maxmem") != None:
    1.32              cfg["maxmem"] = int(sxp.child_value(sxp_cfg, "maxmem"))
    1.33              
    1.34 +        # Convert scheduling parameters to vcpus_params
    1.35 +        if 'vcpus_params' not in cfg:
    1.36 +            cfg['vcpus_params'] = {}
    1.37 +        cfg["vcpus_params"]["weight"] = \
    1.38 +            int(sxp.child_value(sxp_cfg, "cpu_weight", 256))
    1.39 +        cfg["vcpus_params"]["cap"] = \
    1.40 +            int(sxp.child_value(sxp_cfg, "cpu_cap", 0))
    1.41 +
    1.42          # Only extract options we know about.
    1.43          extract_keys = LEGACY_UNSUPPORTED_BY_XENAPI_CFG
    1.44          extract_keys += XENAPI_CFG_TO_LEGACY_CFG.values()
    1.45 @@ -812,8 +814,6 @@ class XendConfig(dict):
    1.46          _set_cfg_if_exists('on_xend_stop')
    1.47          _set_cfg_if_exists('on_xend_start')
    1.48          _set_cfg_if_exists('vcpu_avail')
    1.49 -        _set_cfg_if_exists('cpu_weight')
    1.50 -        _set_cfg_if_exists('cpu_cap')
    1.51          
    1.52          # Parse and store runtime configuration 
    1.53          _set_cfg_if_exists('start_time')
    1.54 @@ -865,6 +865,10 @@ class XendConfig(dict):
    1.55                  self[key] = type_conv(val)
    1.56              else:
    1.57                  self[key] = val
    1.58 +                
    1.59 +        self['vcpus_params']['weight'] = \
    1.60 +            int(self['vcpus_params'].get('weight', 256))
    1.61 +        self['vcpus_params']['cap'] = int(self['vcpus_params'].get('cap', 0))
    1.62  
    1.63      def to_sxp(self, domain = None, ignore_devices = False, ignore = [],
    1.64                 legacy_only = True):
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Sep 26 14:14:16 2007 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Sep 26 14:39:56 2007 +0100
     2.3 @@ -1115,16 +1115,16 @@ class XendDomainInfo:
     2.4          return str(self._resume)
     2.5  
     2.6      def getCap(self):
     2.7 -        return self.info.get('cpu_cap', 0)
     2.8 +        return self.info['vcpus_params']['cap']
     2.9  
    2.10      def setCap(self, cpu_cap):
    2.11 -        self.info['cpu_cap'] = cpu_cap
    2.12 +        self.info['vcpus_params']['cap'] = cpu_cap
    2.13  
    2.14      def getWeight(self):
    2.15 -        return self.info.get('cpu_weight', 256)
    2.16 +        return self.info['vcpus_params']['weight']
    2.17  
    2.18      def setWeight(self, cpu_weight):
    2.19 -        self.info['cpu_weight'] = cpu_weight
    2.20 +        self.info['vcpus_params']['weight'] = cpu_weight
    2.21  
    2.22      def setResume(self, state):
    2.23          self._resume = state
    2.24 @@ -1596,7 +1596,7 @@ class XendDomainInfo:
    2.25      def _initDomain(self):
    2.26          log.debug('XendDomainInfo.initDomain: %s %s',
    2.27                    self.domid,
    2.28 -                  self.info['cpu_weight'])
    2.29 +                  self.info['vcpus_params']['weight'])
    2.30  
    2.31          self._configureBootloader()
    2.32  
    2.33 @@ -1606,7 +1606,8 @@ class XendDomainInfo:
    2.34              if self.info['platform'].get('localtime', 0):
    2.35                  xc.domain_set_time_offset(self.domid)
    2.36  
    2.37 -            xc.domain_setcpuweight(self.domid, self.info['cpu_weight'])
    2.38 +            xc.domain_setcpuweight(self.domid, \
    2.39 +                                   self.info['vcpus_params']['weight'])
    2.40  
    2.41              # repin domain vcpus if a restricted cpus list is provided
    2.42              # this is done prior to memory allocation to aide in memory