Simon Horman
2009-Feb-17 09:23 UTC
[Xen-devel] [rfc] xend: Allow the virtual device and function to be specified for PCI pass-through
There is also an ioemu portion of this patch Signed-off-by: Simon Horman <horms@verge.net.au> Index: xen-unstable.hg/tools/python/xen/xm/create.py ==================================================================--- xen-unstable.hg.orig/tools/python/xen/xm/create.py 2009-02-17 16:13:09.000000000 +0900 +++ xen-unstable.hg/tools/python/xen/xm/create.py 2009-02-17 18:00:50.000000000 +0900 @@ -322,7 +322,7 @@ gopts.var(''disk'', val=''phy:DEV,VDEV,MODE backend driver domain to use for the disk. The option may be repeated to add more than one disk.""") -gopts.var(''pci'', val=''BUS:DEV.FUNC[,msitranslate=0|1]'', +gopts.var(''pci'', val=''PBUS:PDEV.PFUNC[@VDEV[.VFUNC]][,msitranslate=0|1]'', fn=append_value, default=[], use="""Add a PCI device to a domain, using given params (in hex). For example ''pci=c0:02.1''. @@ -681,7 +681,7 @@ def configure_pci(config_devs, vals): """Create the config for pci devices. """ config_pci = [] - for (domain, bus, slot, func, opts) in vals.pci: + for (domain, bus, slot, func, opts, vslot, vfunc) in vals.pci: config_pci_opts = [] d = comma_sep_kv_to_dict(opts) @@ -693,6 +693,10 @@ def configure_pci(config_devs, vals): config_pci_bdf = [''dev'', [''domain'', domain], [''bus'', bus], \ [''slot'', slot], [''func'', func]] + if vslot != ''0x'': + config_pci_bdf.append([''vslot'', vslot]) + if vfunc != ''0x'': + config_pci_bdf.append([''vfunc'', vfunc]) map(f, d.keys()) if len(config_pci_opts)>0: config_pci_bdf.append([''opts'', config_pci_opts]) @@ -1021,7 +1025,9 @@ def preprocess_pci(vals): r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" + \ r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + \ r"(?P<func>[0-7])" + \ - r"(,(?P<opts>.*))?$", pci_dev_str) + r"(,(?P<opts>.*))?" + \ + r"(@((?P<vslot>[0-9a-fA-F])(\.(?P<vfunc>[0-7]))?))?$", \ + pci_dev_str) if pci_match!=None: pci_dev_info = pci_match.groupdict('''') if pci_dev_info[''domain'']=='''': @@ -1031,7 +1037,9 @@ def preprocess_pci(vals): ''0x''+pci_dev_info[''bus''], \ ''0x''+pci_dev_info[''slot''], \ ''0x''+pci_dev_info[''func''], \ - pci_dev_info[''opts''])) + pci_dev_info[''opts''], \ + ''0x''+pci_dev_info[''vslot''], \ + ''0x''+pci_dev_info[''vfunc''])) except IndexError: err(''Error in PCI slot syntax "%s"''%(pci_dev_str)) vals.pci = pci Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py ==================================================================--- xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py 2009-01-30 12:55:45.000000000 +0900 +++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py 2009-02-17 18:00:50.000000000 +0900 @@ -74,6 +74,8 @@ class PciController(DevController): bus = parse_hex(pci_config.get(''bus'', 0)) slot = parse_hex(pci_config.get(''slot'', 0)) func = parse_hex(pci_config.get(''func'', 0)) + vslot = parse_hex(pci_config.get(''vslot'', 0)) + vfunc = parse_hex(pci_config.get(''vfunc'', 0)) opts = pci_config.get(''opts'', '''') if len(opts) > 0: @@ -88,6 +90,7 @@ class PciController(DevController): back[''dev-%i'' % pcidevid] = "%04x:%02x:%02x.%01x" % \ (domain, bus, slot, func) back[''uuid-%i'' % pcidevid] = pci_config.get(''uuid'', '''') + back[''vdevfn-%i'' % pcidevid] = "%02x.%01x" % (vslot, vfunc) pcidevid += 1 if vslots != "": _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel