direct-io.hg
changeset 12639:8b91546569d7
[XEND] Catch TypeErrors when unexpected SXP is encountered.
Signed-off-by: Alastair Tse <atse@xensource.com>
Signed-off-by: Alastair Tse <atse@xensource.com>
author | Alastair Tse <atse@xensource.com> |
---|---|
date | Thu Nov 30 15:19:01 2006 +0000 (2006-11-30) |
parents | b2f5f1251330 |
children | 18b4b0fdf56b |
files | tools/python/xen/xend/XendConfig.py |
line diff
1.1 --- a/tools/python/xen/xend/XendConfig.py Thu Nov 30 14:53:14 2006 +0000 1.2 +++ b/tools/python/xen/xend/XendConfig.py Thu Nov 30 15:19:01 2006 +0000 1.3 @@ -398,14 +398,14 @@ class XendConfig(dict): 1.4 1.5 for key in extract_keys: 1.6 val = sxp.child_value(sxp_cfg, key) 1.7 - if val: 1.8 + if val != None: 1.9 try: 1.10 - try: 1.11 - cfg[key] = LEGACY_CFG_TYPES[key](val) 1.12 - except KeyError: 1.13 - cfg[key] = val 1.14 - except ValueError: 1.15 - pass 1.16 + cfg[key] = LEGACY_CFG_TYPES[key](val) 1.17 + except KeyError: 1.18 + cfg[key] = val 1.19 + except (TypeError, ValueError), e: 1.20 + log.warn("Unable to parse key %s: %s: %s" % 1.21 + (key, str(val), e)) 1.22 1.23 # Parsing the device SXP's. In most cases, the SXP looks 1.24 # like this: 1.25 @@ -463,7 +463,7 @@ class XendConfig(dict): 1.26 image_sxp = sxp.child_value(sxp_cfg, 'image', []) 1.27 if image_sxp: 1.28 image_vcpus = sxp.child_value(image_sxp, 'vcpus') 1.29 - if image_vcpus is not None: 1.30 + if image_vcpus != None: 1.31 try: 1.32 if 'vcpus_number' not in cfg: 1.33 cfg['vcpus_number'] = int(image_vcpus)