Assign Hardware to DomU with PCIBack as module

From Xen
Revision as of 19:00, 27 November 2011 by GarveyPatrickD (talk | contribs) (Removed superfluous <nowiki></nowiki> pairs.)
Jump to navigationJump to search


If the Dom0 XenLinux kernel is built with pciback as a module, attempting to use the kernel command-line parameter pciback.hide won't work. This includes loading pciback in an initrd. This means that if you wish to assign hardware to a DomU another method is needed.

There are two possibilities.

Option 1: Late Binding

Use late binding as described in section 5.3.1.3 of the user manual and put something like the following in an init script (/etc/rc.local will work on Fedora) to be executed before Xen domains. You can find the correct value for $BDF using lspci. For more information on BDF notation see Bus:Device.Function (BDF) Notation.

BDF=0000:05:02.0
# Unbind a PCI function from its driver as necessary
[ ! -e /sys/bus/pci/devices/$BDF/driver/unbind ] || \
        echo -n $BDF > /sys/bus/pci/devices/$BDF/driver/unbind
# Add a new slot to the PCI Backend's list
echo -n $BDF > /sys/bus/pci/drivers/pciback/new_slot
# Now that the backend is watching for the slot, bind to it
echo -n $BDF > /sys/bus/pci/drivers/pciback/bind

This has the disadvantage that if pciback is unloaded for any reason, you'll have to do it again.

Option 2: Modify Config File

Add a line to /etc/modprobe.conf to pass the hide parameter to pciback

# hide (0000:05:02.0)
options pciback hide=(0000:05:02.0)
# hide more pci devices
options pciback hide=(0000:05:02.0)(0000:07:00.0)(0000:07:00.1)(0000:00:1d.0)

On its own, that will only work if no driver is loaded for the PCI function before pciback. That is, it won't unbind a driver that's already bound to it. So it's necessary to make sure that pciback is loaded before any such driver. Supposing that the usual driver for the PCI function is skge, we can make that happen by adding a line like this:

install skge /sbin/modprobe pciback ; /sbin/modprobe --first-time --ignore-install skge

In other words, the above says that whenever skge is asked to be loaded, pciback should be loaded first. Note that to make use of this, a Linux kernel running in the guest domain has to have been compiled with pci frontend support. Look under "bus options (PCI etc)" for Xen PCI Frontend in the kernel configuration.

At time of writing, the Fedora kernel-xen rpm for x86_64 2.6.17-1.2157_FC5.x86_64.rpm is compiled with it off.