ia64/xen-unstable

changeset 19423:538a64b1ed63

xend: specify the slot for pass-through devices

Currently a slot may be specified for a hot-plug device,
but not for a pass-through device that is inserted at boot time.
This patch adds support for the latter.

The syntax is:
BUS:DEV.FUNC[@VSLOT]
e.g: 0000:00:1d:0@7

This may be important as recent changes that allow any free PCI
slot to be used for pass-through (and hotplug) may case pass-through
devices to be assigned in different locations to before. Amongst
other things, specifying the slot will allow users to move them
back, if there is a need.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Mar 20 12:09:20 2009 +0000 (2009-03-20)
parents 2cd2e78d7c2d
children 1dd7b640d953
files tools/python/xen/xend/server/pciif.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xend/server/pciif.py	Fri Mar 20 10:37:12 2009 +0000
     1.2 +++ b/tools/python/xen/xend/server/pciif.py	Fri Mar 20 12:09:20 2009 +0000
     1.3 @@ -75,6 +75,7 @@ class PciController(DevController):
     1.4              bus = parse_hex(pci_config.get('bus', 0))
     1.5              slot = parse_hex(pci_config.get('slot', 0))
     1.6              func = parse_hex(pci_config.get('func', 0))            
     1.7 +            vslot = parse_hex(pci_config.get('vslot', 0))
     1.8  
     1.9              opts = pci_config.get('opts', '')
    1.10              if len(opts) > 0:
     2.1 --- a/tools/python/xen/xm/create.py	Fri Mar 20 10:37:12 2009 +0000
     2.2 +++ b/tools/python/xen/xm/create.py	Fri Mar 20 12:09:20 2009 +0000
     2.3 @@ -1,4 +1,4 @@
     2.4 -#============================================================================
     2.5 +#============================================================================UTO
     2.6  # This library is free software; you can redistribute it and/or
     2.7  # modify it under the terms of version 2.1 of the GNU Lesser General Public
     2.8  # License as published by the Free Software Foundation.
     2.9 @@ -32,6 +32,7 @@ from xen.xend import PrettyPrint as SXPP
    2.10  from xen.xend import osdep
    2.11  import xen.xend.XendClient
    2.12  from xen.xend.XendBootloader import bootloader
    2.13 +from xen.xend.XendConstants import *
    2.14  from xen.xend.server.DevConstants import xenbusState
    2.15  from xen.util import blkif
    2.16  from xen.util import vscsi_util
    2.17 @@ -322,10 +323,12 @@ gopts.var('disk', val='phy:DEV,VDEV,MODE
    2.18            backend driver domain to use for the disk.
    2.19            The option may be repeated to add more than one disk.""")
    2.20  
    2.21 -gopts.var('pci', val='BUS:DEV.FUNC[,msitranslate=0|1][,power_mgmt=0|1]',
    2.22 +gopts.var('pci', val='BUS:DEV.FUNC[@VSLOT][,msitranslate=0|1][,power_mgmt=0|1]',
    2.23            fn=append_value, default=[],
    2.24            use="""Add a PCI device to a domain, using given params (in hex).
    2.25            For example 'pci=c0:02.1'.
    2.26 +          If VSLOT is supplied the device will be inserted into that
    2.27 +          virtual slot in the guest, else a free slot is selected.
    2.28            If msitranslate is set, MSI-INTx translation is enabled if possible.
    2.29            Guest that doesn't support MSI will get IO-APIC type IRQs
    2.30            translated from physical MSI, HVM only. Default is 1.
    2.31 @@ -696,7 +699,7 @@ def configure_pci(config_devs, vals):
    2.32      """Create the config for pci devices.
    2.33      """
    2.34      config_pci = []
    2.35 -    for (domain, bus, slot, func, opts) in vals.pci:
    2.36 +    for (domain, bus, slot, func, vslot, opts) in vals.pci:
    2.37          config_pci_opts = []
    2.38          d = comma_sep_kv_to_dict(opts)
    2.39  
    2.40 @@ -707,7 +710,7 @@ def configure_pci(config_devs, vals):
    2.41              config_pci_opts.append([k, d[k]])
    2.42  
    2.43          config_pci_bdf = ['dev', ['domain', domain], ['bus', bus], \
    2.44 -                          ['slot', slot], ['func', func]]
    2.45 +                          ['slot', slot], ['func', func], ['vslot', vslot]]
    2.46          map(f, d.keys())
    2.47          if len(config_pci_opts)>0:
    2.48              config_pci_bdf.append(['opts', config_pci_opts])
    2.49 @@ -1054,16 +1057,21 @@ def preprocess_pci(vals):
    2.50                  r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" + \
    2.51                  r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + \
    2.52                  r"(?P<func>[0-7])" + \
    2.53 -                r"(,(?P<opts>.*))?$", pci_dev_str)
    2.54 +                r"(@(?P<vslot>[0-9a-fA-F]))?" + \
    2.55 +                r"(,(?P<opts>.*))?$", \
    2.56 +                pci_dev_str)
    2.57          if pci_match!=None:
    2.58              pci_dev_info = pci_match.groupdict('')
    2.59              if pci_dev_info['domain']=='':
    2.60                  pci_dev_info['domain']='0'
    2.61 +            if pci_dev_info['vslot']=='':
    2.62 +                pci_dev_info['vslot']="%02x" % AUTO_PHP_SLOT
    2.63              try:
    2.64                  pci.append( ('0x'+pci_dev_info['domain'], \
    2.65                          '0x'+pci_dev_info['bus'], \
    2.66                          '0x'+pci_dev_info['slot'], \
    2.67                          '0x'+pci_dev_info['func'], \
    2.68 +                        '0x'+pci_dev_info['vslot'], \
    2.69                          pci_dev_info['opts']))
    2.70              except IndexError:
    2.71                  err('Error in PCI slot syntax "%s"'%(pci_dev_str))