ia64/xen-unstable

changeset 19780:d8b2b1712ea6

xend: pass-through: Add pci_tuple_to_dict()

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 17 07:38:03 2009 +0100 (2009-06-17)
parents bc7715954087
children 85fdfb7da88c
files tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xm/create.py	Wed Jun 17 07:37:26 2009 +0100
     1.2 +++ b/tools/python/xen/xm/create.py	Wed Jun 17 07:38:03 2009 +0100
     1.3 @@ -38,7 +38,7 @@ 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 pci_opts_list_to_sxp, \
     1.8 +from xen.util.pci import dev_dict_to_sxp, \
     1.9                           parse_pci_name_extended, PciDeviceParseError
    1.10  
    1.11  from xen.xm.opts import *
    1.12 @@ -707,12 +707,9 @@ def configure_pci(config_devs, vals):
    1.13      """Create the config for pci devices.
    1.14      """
    1.15      config_pci = []
    1.16 -    for (domain, bus, slot, func, vslot, opts) in vals.pci:
    1.17 -        config_pci_bdf = ['dev', ['domain', domain], ['bus', bus], \
    1.18 -                          ['slot', slot], ['func', func],
    1.19 -                          ['vslot', vslot]]
    1.20 -        config_opts = pci_opts_list_to_sxp(opts)
    1.21 -        config_pci.append(sxp.merge(config_pci_bdf, config_opts))
    1.22 +    for pci_tuple in vals.pci:
    1.23 +        pci_dev = pci_tuple_to_dict(pci_tuple)
    1.24 +        config_pci.append(dev_dict_to_sxp(pci_dev))
    1.25  
    1.26      if len(config_pci)>0:
    1.27          config_pci.insert(0, 'pci')
    1.28 @@ -1050,6 +1047,16 @@ def pci_dict_to_tuple(dev):
    1.29      return (dev['domain'], dev['bus'], dev['slot'], dev['func'],
    1.30              dev['vslot'], dev.get('opts', []))
    1.31  
    1.32 +def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts)):
    1.33 +    pci_dev = { 'domain': domain,
    1.34 +                'bus':    bus,
    1.35 +                'slot':   slot,
    1.36 +                'func':   func,
    1.37 +                'vslot':  vslot}
    1.38 +    if len(opts) > 0:
    1.39 +        pci_dev['opts'] = opts
    1.40 +    return pci_dev
    1.41 +
    1.42  def preprocess_pci(vals):
    1.43      if not vals.pci:
    1.44          return