direct-io.hg

changeset 12788:61883e3168a6

[XEND] Sync Xen API with newer VDB and VIF specification.

Fix breakage with storing VIF and VBD refs, remove extraneous
debugging. Also fixing some type errors in default values for Xen API
if things are missing in XendConfig.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Dec 07 16:08:44 2006 +0000 (2006-12-07)
parents 93314655b16f
children ec9259920f85
files tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Thu Dec 07 14:40:13 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Thu Dec 07 16:08:44 2006 +0000
     1.3 @@ -1036,8 +1036,8 @@ class XendAPI:
     1.4      #       regular xm created VBDs
     1.5  
     1.6      VBD_attr_ro = ['image',
     1.7 -                   'IO_bandwidth_incoming_kbs',
     1.8 -                   'IO_bandwidth_outgoing_kbs']
     1.9 +                   'io_read_kbs',
    1.10 +                   'io_write_kbs']
    1.11      VBD_attr_rw = ['VM',
    1.12                     'VDI',
    1.13                     'device',
    1.14 @@ -1113,10 +1113,8 @@ class XendAPI:
    1.15      # Xen API: Class VIF
    1.16      # ----------------------------------------------------------------
    1.17  
    1.18 -    VIF_attr_ro = ['network_read_kbs',
    1.19 -                   'network_write_kbs',
    1.20 -                   'IO_bandwidth_incoming_kbs',
    1.21 -                   'IO_bandwidth_outgoing_kbs']
    1.22 +    VIF_attr_ro = ['io_read_kbs',
    1.23 +                   'io_write_kbs']
    1.24      VIF_attr_rw = ['name',
    1.25                     'type',
    1.26                     'device',
    1.27 @@ -1138,6 +1136,7 @@ class XendAPI:
    1.28              return xen_api_error(XEND_ERROR_VIF_INVALID)
    1.29          valid_vif_keys = self.VIF_attr_ro + self.VIF_attr_rw + \
    1.30                           self.Base_attr_ro + self.Base_attr_rw
    1.31 +
    1.32          for k in cfg.keys():
    1.33              if k not in valid_vif_keys:
    1.34                  del cfg[k]
     2.1 --- a/tools/python/xen/xend/XendConfig.py	Thu Dec 07 14:40:13 2006 +0000
     2.2 +++ b/tools/python/xen/xend/XendConfig.py	Thu Dec 07 16:08:44 2006 +0000
     2.3 @@ -925,7 +925,6 @@ class XendConfig(dict):
     2.4  
     2.5              if dev_type == 'vif' and 'ip' in dev_info:
     2.6                  dev_info['ip'] = _get_config_ipaddr(config)
     2.7 -                log.debug('XendConfig: IP Address: %s' % dev_info['ip'])
     2.8  
     2.9              if dev_type == 'vbd':
    2.10                  if dev_info.get('dev', '').startswith('ioemu:'):
    2.11 @@ -944,12 +943,12 @@ class XendConfig(dict):
    2.12                  param = '%s_refs' % dev_type
    2.13                  if param not in target:
    2.14                      target[param] = []
    2.15 -                if dev_uuid in target[param]:
    2.16 +                if dev_uuid not in target[param]:
    2.17                      target[param].append(dev_uuid)
    2.18              elif dev_type in ('tap',):
    2.19                  if 'vbd_refs' not in target:
    2.20                      target['vbd_refs'] = []
    2.21 -                if dev_uuid in target['vbd_refs']:
    2.22 +                if dev_uuid not in target['vbd_refs']:
    2.23                      target['vbd_refs'].append(dev_uuid)
    2.24  
    2.25              return dev_uuid
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Dec 07 14:40:13 2006 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Dec 07 16:08:44 2006 +0000
     3.3 @@ -1780,13 +1780,13 @@ class XendDomainInfo:
     3.4          return dom_uuid
     3.5      
     3.6      def get_memory_static_max(self):
     3.7 -        return self.info.get('memory_static_max')
     3.8 +        return self.info.get('memory_static_max', 0)
     3.9      def get_memory_static_min(self):
    3.10 -        return self.info.get('memory_static_min')
    3.11 +        return self.info.get('memory_static_min', 0)
    3.12      def get_memory_dynamic_max(self):
    3.13 -        return self.info.get('memory_dynamic_min')
    3.14 +        return self.info.get('memory_dynamic_min', 0)
    3.15      def get_memory_dynamic_min(self):
    3.16 -        return self.info.get('memory_dynamic_max')
    3.17 +        return self.info.get('memory_dynamic_max', 0)
    3.18      
    3.19      
    3.20      def get_vcpus_policy(self):
    3.21 @@ -1820,7 +1820,7 @@ class XendDomainInfo:
    3.22      def get_builder(self):
    3.23          return self.info.get('builder', 0)
    3.24      def get_boot_method(self):
    3.25 -        return self.info.get('boot_method', '')
    3.26 +        return self.info.get('boot_method', XEN_API_BOOT_TYPE[2])
    3.27      def get_kernel_image(self):
    3.28          return self.info.get('kernel_kernel', '')
    3.29      def get_kernel_initrd(self):
    3.30 @@ -1830,7 +1830,7 @@ class XendDomainInfo:
    3.31      def get_grub_cmdline(self):
    3.32          return '' # TODO
    3.33      def get_pci_bus(self):
    3.34 -        return 0 # TODO
    3.35 +        return '' # TODO
    3.36      def get_tools_version(self):
    3.37          return {} # TODO
    3.38      def get_other_config(self):
    3.39 @@ -1925,18 +1925,16 @@ class XendDomainInfo:
    3.40                      
    3.41              config['network'] = '' # Invalid for Xend
    3.42              config['MTU'] = 1500 # TODO
    3.43 -            config['network_read_kbs'] = 0.0
    3.44 -            config['network_write_kbs'] = 0.0
    3.45 -            config['IO_bandwidth_incoming_kbs'] = 0.0
    3.46 -            config['IO_bandwidth_outgoing_kbs'] = 0.0
    3.47 +            config['io_read_kbs'] = 0.0
    3.48 +            config['io_write_kbs'] = 0.0
    3.49  
    3.50          if dev_class == 'vbd':
    3.51 -            config['VDI'] = '' # TODO
    3.52 +            config['VDI'] = config.get('VDI', '')
    3.53              config['device'] = config.get('dev', '')
    3.54              config['driver'] = 'paravirtualised' # TODO
    3.55              config['image'] = config.get('uname', '')
    3.56 -            config['IO_bandwidth_incoming_kbs'] = 0.0
    3.57 -            config['IO_bandwidth_outgoing_kbs'] = 0.0
    3.58 +            config['io_read_kbs'] = 0.0
    3.59 +            config['io_write_kbs'] = 0.0
    3.60              if config['mode'] == 'r':
    3.61                  config['mode'] = 'RO'
    3.62              else:
    3.63 @@ -2050,27 +2048,7 @@ class XendDomainInfo:
    3.64          return dev_uuid
    3.65  
    3.66      def has_device(self, dev_class, dev_uuid):
    3.67 -        return (dev_uuid in self.info['%s_refs' % dev_class])
    3.68 -
    3.69 -    """
    3.70 -        def stateChar(name):
    3.71 -            if name in self.info:
    3.72 -                if self.info[name]:
    3.73 -                    return name[0]
    3.74 -                else:
    3.75 -                    return '-'
    3.76 -            else:
    3.77 -                return '?'
    3.78 -
    3.79 -        state = reduce(lambda x, y: x + y, map(stateChar, DOM_STATES_OLD))
    3.80 -
    3.81 -        sxpr.append(['state', state])
    3.82 -
    3.83 -        if self.store_mfn:
    3.84 -            sxpr.append(['store_mfn', self.store_mfn])
    3.85 -        if self.console_mfn:
    3.86 -            sxpr.append(['console_mfn', self.console_mfn])
    3.87 -    """
    3.88 +        return (dev_uuid in self.info['%s_refs' % dev_class.lower()])
    3.89  
    3.90      def __str__(self):
    3.91          return '<domain id=%s name=%s memory=%s state=%s>' % \