ia64/xen-unstable

changeset 13257:48c9028e6f8e

[XEND] Parse as much device SXP as possible.

Fix vtpm device check and xm list --long listing detached block devices.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Jan 04 15:32:26 2007 +0000 (2007-01-04)
parents b82e1ed0870a
children 98dadb3df5ca
files tools/python/xen/xend/XendConfig.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Thu Jan 04 15:08:40 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Thu Jan 04 15:32:26 2007 +0000
     1.3 @@ -508,8 +508,12 @@ class XendConfig(dict):
     1.4                  pci_devs = []
     1.5                  for pci_dev in sxp.children(config, 'dev'):
     1.6                      pci_dev_info = {}
     1.7 -                    for opt, val in pci_dev[1:]:
     1.8 -                        pci_dev_info[opt] = val
     1.9 +                    for opt_val in pci_dev[1:]:
    1.10 +                        try:
    1.11 +                            opt, val = opt_val
    1.12 +                            pci_dev_info[opt] = val
    1.13 +                        except TypeError:
    1.14 +                            pass
    1.15                      pci_devs.append(pci_dev_info)
    1.16                  
    1.17                  cfg['devices'][pci_devs_uuid] = (dev_type,
    1.18 @@ -572,7 +576,6 @@ class XendConfig(dict):
    1.19          if 'security' in cfg and isinstance(cfg['security'], str):
    1.20              cfg['security'] = sxp.from_string(cfg['security'])
    1.21  
    1.22 -        # TODO: get states
    1.23          old_state = sxp.child_value(sxp_cfg, 'state')
    1.24          if old_state:
    1.25              for i in range(len(CONFIG_OLD_DOM_STATES)):
    1.26 @@ -855,14 +858,15 @@ class XendConfig(dict):
    1.27              for cls in XendDevices.valid_devices():
    1.28                  found = False
    1.29                  
    1.30 -                # figure if there is a device that is running
    1.31 +                # figure if there is a dev controller is valid and running
    1.32                  if domain:
    1.33                      try:
    1.34                          controller = domain.getDeviceController(cls)
    1.35                          configs = controller.configurations()
    1.36                          for config in configs:
    1.37                              sxpr.append(['device', config])
    1.38 -                            found = True
    1.39 +
    1.40 +                        found = True
    1.41                      except:
    1.42                          log.exception("dumping sxp from device controllers")
    1.43                          pass
    1.44 @@ -923,11 +927,12 @@ class XendConfig(dict):
    1.45              dev_type = sxp.name(config)
    1.46              dev_info = {}
    1.47  
    1.48 -            try:
    1.49 -                for opt, val in config[1:]:
    1.50 +            for opt_val in config[1:]:
    1.51 +                try:
    1.52 +                    opt, val = opt_val
    1.53                      dev_info[opt] = val
    1.54 -            except ValueError:
    1.55 -                pass # SXP has no options for this device
    1.56 +                except (TypeError, ValueError): # unpack error
    1.57 +                    pass
    1.58  
    1.59              if dev_type == 'vbd':
    1.60                  if dev_info.get('dev', '').startswith('ioemu:'):
    1.61 @@ -996,7 +1001,7 @@ class XendConfig(dict):
    1.62                  self['vbd_refs'].append(dev_uuid)                
    1.63                  return dev_uuid
    1.64  
    1.65 -            elif dev_type in ('vtpm'):
    1.66 +            elif dev_type == 'vtpm':
    1.67                  if cfg_xenapi.get('type'):
    1.68                      dev_info['type'] = cfg_xenapi.get('type')
    1.69  
    1.70 @@ -1019,11 +1024,12 @@ class XendConfig(dict):
    1.71              dev_type = sxp.name(config)
    1.72              dev_info = {}
    1.73  
    1.74 -            try:
    1.75 -                for opt, val in config[1:]:
    1.76 -                    self['devices'][opt] = val
    1.77 -            except ValueError:
    1.78 -                pass # SXP has no options for this device
    1.79 +            for opt_val in config[1:]:
    1.80 +                try:
    1.81 +                    opt, val = opt_val
    1.82 +                    self['devices'][dev_uuid][opt] = val
    1.83 +                except (TypeError, ValueError):
    1.84 +                    pass # no value for this config option
    1.85              
    1.86              return True
    1.87