ia64/xen-unstable

changeset 12690:d9b5e34c4e5c

[XEND] Checks to make sure the image type is valid in configuration

The 'builder' (eg. image type) should either be 'hvm' or 'linux' as
image.py only supports these at the moment.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Nov 30 14:51:46 2006 +0000 (2006-11-30)
parents 96621d417bd4
children b2f5f1251330
files tools/python/xen/xend/XendConfig.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Thu Nov 30 14:50:27 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Thu Nov 30 14:51:46 2006 +0000
     1.3 @@ -328,9 +328,14 @@ class XendConfig(dict):
     1.4                  raise XendConfigError('Invalid event handling mode: ' +
     1.5                                        event)
     1.6  
     1.7 +    def _builder_sanity_check(self):
     1.8 +        if self['builder'] not in ('hvm', 'linux'):
     1.9 +            raise XendConfigError('Invalid builder configuration')
    1.10 +
    1.11      def validate(self):
    1.12          self._memory_sanity_check()
    1.13          self._actions_sanity_check()
    1.14 +        self._builder_sanity_check()
    1.15  
    1.16      def _dominfo_to_xapi(self, dominfo):
    1.17          self['domid'] = dominfo['domid']
    1.18 @@ -665,7 +670,14 @@ class XendConfig(dict):
    1.19          officially supported by the Xen API but is required for
    1.20          the rest of Xend to function.
    1.21          """
    1.22 -        pass
    1.23 +
    1.24 +        # populate image
    1.25 +        self['image']['type'] = self['builder']
    1.26 +        if self['builder'] == 'hvm':
    1.27 +            self['image']['hvm'] = {}
    1.28 +            for xapi, cfgapi in XENAPI_HVM_CFG.items():
    1.29 +                self['image']['hvm'][cfgapi] = self[xapi]
    1.30 +            
    1.31  
    1.32      def _get_old_state_string(self):
    1.33          """Returns the old xm state string.
    1.34 @@ -868,13 +880,14 @@ class XendConfig(dict):
    1.35              
    1.36              elif dev_type in ('vbd', 'tap'):
    1.37                  if dev_type == 'vbd':
    1.38 -                    dev_info['uname'] = cfg_xenapi.get('image', None)
    1.39 +                    dev_info['uname'] = cfg_xenapi.get('image', '')
    1.40                      dev_info['dev'] = '%s:disk' % cfg_xenapi.get('device')
    1.41                  elif dev_type == 'tap':
    1.42                      dev_info['uname'] = 'tap:qcow:%s' % cfg_xenapi.get('image')
    1.43                      dev_info['dev'] = '%s:disk' % cfg_xenapi.get('device')
    1.44                      
    1.45                  dev_info['driver'] = cfg_xenapi.get('driver')
    1.46 +                dev_info['VDI'] = cfg_xenapi.get('VDI', '')
    1.47                      
    1.48                  if cfg_xenapi.get('mode') == 'RW':
    1.49                      dev_info['mode'] = 'w'