ia64/xen-unstable

diff tools/python/xen/util/pci.py @ 19758:0573bbe19499

xend: pass-through: sxp.merge() cant deal with values being a list

sxp.merge() can't deal with values being a list so instead
of storing pci options as:

[ 'opts', [ 'key1' 'value1'], [ 'key2', 'value2'], ...]

store them as:

[ 'opts', [ 'key1' 'value1'], ['opts', [ 'key2', 'value2']], ...

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 16 11:37:41 2009 +0100 (2009-06-16)
parents 08de8ec655c2
children 11c3f4e786b3
line diff
     1.1 --- a/tools/python/xen/util/pci.py	Tue Jun 16 11:36:40 2009 +0100
     1.2 +++ b/tools/python/xen/util/pci.py	Tue Jun 16 11:37:41 2009 +0100
     1.3 @@ -118,14 +118,26 @@ def PCI_BDF(domain, bus, slot, func):
     1.4      return (((domain & 0xffff) << 16) | ((bus & 0xff) << 8) |
     1.5              PCI_DEVFN(slot, func))
     1.6  
     1.7 +def check_pci_opts(opts):
     1.8 +    def f((k, v)):
     1.9 +        if k not in ['msitranslate', 'power_mgmt'] or \
    1.10 +           not v.lower() in ['0', '1', 'yes', 'no']:
    1.11 +            raise PciDeviceParseError('Invalid pci option %s=%s: ' % (k, v))
    1.12 +
    1.13 +    map(f, opts)
    1.14 +
    1.15  def serialise_pci_opts(opts):
    1.16 -    return reduce(lambda x, y: x+','+y, map(lambda (x, y): x+'='+y, opts))
    1.17 +    return ','.join(map(lambda x: '='.join(x), opts))
    1.18  
    1.19  def split_pci_opts(opts):
    1.20 -    return map(lambda x: x.split('='), opts.split(','))
    1.21 +    return map(lambda x: x.split('='),
    1.22 +               filter(lambda x: x != '', opts.split(',')))
    1.23  
    1.24  def pci_opts_list_to_sxp(list):
    1.25 -    ['dev'] + map(lambda x: ['opts', x], list)
    1.26 +    return ['dev'] + map(lambda x: ['opts', x], list)
    1.27 +
    1.28 +def pci_opts_list_from_sxp(dev):
    1.29 +    return map(lambda x: sxp.children(x)[0], sxp.children(dev, 'opts'))
    1.30  
    1.31  def parse_hex(val):
    1.32      try: