Assign Hardware to DomU with PCIBack as module: Difference between revisions

From Xen
Jump to navigationJump to search
(Migrated page)
 
(removed outdated fedora info)
 
(8 intermediate revisions by 3 users not shown)
Line 10: Line 10:
There are two possibilities.
There are two possibilities.


= Option 1: Late Binding =
# Use late binding as described in [http://www.cl.cam.ac.uk/Research/SRG/netos/xen/readmes/user/user.html#SECTION03231300000000000000 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 <code><nowiki>lspci</nowiki></code>. For more information on BDF notation see Self:BDFNotation.


Use late binding as described in [http://www.cl.cam.ac.uk/Research/SRG/netos/xen/readmes/user/user.html#SECTION03231300000000000000 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 <code>lspci</code>. For more information on BDF notation see [[Bus:Device.Function (BDF) Notation]].
<pre><nowiki>
<pre>
BDF=0000:05:02.0
BDF=0000:05:02.0
# Unbind a PCI function from its driver as necessary
# Unbind a PCI function from its driver as necessary
Line 21: Line 22:
echo -n $BDF > /sys/bus/pci/drivers/pciback/new_slot
echo -n $BDF > /sys/bus/pci/drivers/pciback/new_slot
# Now that the backend is watching for the slot, bind to it
# Now that the backend is watching for the slot, bind to it
echo -n $BDF > /sys/bus/pci/drivers/pciback/bind</nowiki></pre>
echo -n $BDF > /sys/bus/pci/drivers/pciback/bind</pre>


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


= Option 2: Modify Config File =
This has the disadvantage that if pciback is unloaded for any reason, you'll have to do it again.


# Add a line to /etc/modprobe.conf to pass the hide parameter to pciback
Add a line to /etc/modprobe.conf to pass the hide parameter to pciback
<pre><nowiki>
<pre>
# hide (0000:05:02.0)
# hide (0000:05:02.0)
options pciback hide=(0000:05:02.0)
options pciback hide=(0000:05:02.0)
# hide more pci devices
# hide more pci devices
options pciback hide=(0000:05:02.0)(0000:07:00.0)(0000:07:00.1)(0000:00:1d.0)
options pciback hide=(0000:05:02.0)(0000:07:00.0)(0000:07:00.1)(0000:00:1d.0)
</nowiki></pre>
</pre>


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:
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:
<pre><nowiki>
<pre>
install skge /sbin/modprobe pciback ; /sbin/modprobe --first-time --ignore-install skge</nowiki></pre>
install skge /sbin/modprobe pciback ; /sbin/modprobe --first-time --ignore-install skge</pre>


In words, the above says that whenever skge is asked to be loaded, pciback should be loaded first.
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.
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.


[[Category:Xen]]
[[Category:Xen]]

Latest revision as of 06:42, 4 January 2012


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.