ia64/xen-unstable

changeset 19761:b52a91a45c65

xend: pass-through: Use common parsing code in preprocess_pci()

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 16 11:41:31 2009 +0100 (2009-06-16)
parents 4bc1347b9b86
children d96cf4c974d5
files tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xm/create.py	Tue Jun 16 11:39:02 2009 +0100
     1.2 +++ b/tools/python/xen/xm/create.py	Tue Jun 16 11:41:31 2009 +0100
     1.3 @@ -38,8 +38,8 @@ from xen.util import vscsi_util
     1.4  import xen.util.xsm.xsm as security
     1.5  from xen.xm.main import serverType, SERVER_XEN_API, get_single_vm
     1.6  from xen.util import utils, auxbin
     1.7 -from xen.util.pci import split_pci_opts, check_pci_opts, \
     1.8 -                         pci_opts_list_to_sxp
     1.9 +from xen.util.pci import pci_opts_list_to_sxp, \
    1.10 +                         parse_pci_name_extended, PciDeviceParseError
    1.11  
    1.12  from xen.xm.opts import *
    1.13  
    1.14 @@ -711,14 +711,7 @@ def configure_pci(config_devs, vals):
    1.15          config_pci_bdf = ['dev', ['domain', domain], ['bus', bus], \
    1.16                            ['slot', slot], ['func', func],
    1.17                            ['vslot', vslot]]
    1.18 -
    1.19 -        opts_list = split_pci_opts(opts)
    1.20 -        try:
    1.21 -            check_pci_opts(opts_list)
    1.22 -        except PciDeviceParseError, ex:
    1.23 -            err(str(ex))
    1.24 -
    1.25 -        config_opts = pci_opts_list_to_sxp(split_pci_opts(opts))
    1.26 +        config_opts = pci_opts_list_to_sxp(opts)
    1.27          config_pci.append(sxp.merge(config_pci_bdf, config_opts))
    1.28  
    1.29      if len(config_pci)>0:
    1.30 @@ -1053,33 +1046,18 @@ def preprocess_cpuid(vals, attr_name):
    1.31                  cpuid[input][res['reg']] = res['val'] # new register
    1.32              setattr(vals, attr_name, cpuid)
    1.33  
    1.34 +def pci_dict_to_tuple(dev):
    1.35 +    return (dev['domain'], dev['bus'], dev['slot'], dev['func'],
    1.36 +            dev['vslot'], dev.get('opts', []))
    1.37 +
    1.38  def preprocess_pci(vals):
    1.39 -    if not vals.pci: return
    1.40 -    pci = []
    1.41 -    for pci_dev_str in vals.pci:
    1.42 -        pci_match = re.match(r"((?P<domain>[0-9a-fA-F]{1,4})[:,])?" + \
    1.43 -                r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" + \
    1.44 -                r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + \
    1.45 -                r"(?P<func>[0-7])" + \
    1.46 -                r"(@(?P<vslot>[01]?[0-9a-fA-F]))?" + \
    1.47 -                r"(,(?P<opts>.*))?$", \
    1.48 -                pci_dev_str)
    1.49 -        if pci_match!=None:
    1.50 -            pci_dev_info = pci_match.groupdict('')
    1.51 -            if pci_dev_info['domain']=='':
    1.52 -                pci_dev_info['domain']='0'
    1.53 -            if pci_dev_info['vslot']=='':
    1.54 -                pci_dev_info['vslot']="%02x" % AUTO_PHP_SLOT
    1.55 -            try:
    1.56 -                pci.append( ('0x'+pci_dev_info['domain'], \
    1.57 -                        '0x'+pci_dev_info['bus'], \
    1.58 -                        '0x'+pci_dev_info['slot'], \
    1.59 -                        '0x'+pci_dev_info['func'], \
    1.60 -                        '0x'+pci_dev_info['vslot'], \
    1.61 -                        pci_dev_info['opts']))
    1.62 -            except IndexError:
    1.63 -                err('Error in PCI slot syntax "%s"'%(pci_dev_str))
    1.64 -    vals.pci = pci
    1.65 +    if not vals.pci:
    1.66 +        return
    1.67 +    try:
    1.68 +        vals.pci = map(pci_dict_to_tuple,
    1.69 +                       map(parse_pci_name_extended, vals.pci))
    1.70 +    except PciDeviceParseError, ex:
    1.71 +        err(str(ex))
    1.72  
    1.73  def preprocess_vscsi(vals):
    1.74      if not vals.vscsi: return