16.2. Using SR-IOV
This section covers attaching Virtual Function to a guest as an additional network device.
SR-IOV requires Intel VT-d support.
Important
Xen requires additional kernel arguments to use SR-IOV. Modify the
/boot/grub/grub.conf
file to enable SR-IOV. To enable SR-IOV with Xen for Intel systems append the pci_pt_e820_access=on
parameter to the kernel.
default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-192.el5xen) root (hd0,0) kernel /xen.gz-2.6.18-192.el5 iommu=1 module /vmlinuz-2.6.18-192.el5xen ro root=/dev/VolGroup00/LogVol00 pci_pt_e820_access=on module /initrd-2.6.18-192.el5xen.img
Procedure 16.1. Attach an SR-IOV network device
Enable Intel VT-d in BIOS and in the kernel
Enable Intel VT-D in BIOS. See Procedure 15.1, “Preparing an Intel system for PCI passthrough” for more information on enabling Intel VT-d in BIOS and the kernel, or see your system manufacturer's documentation for specific instructions.Verify support
Verify if the PCI device with SR-IOV capabilities are detected. This example lists an Intel 82576 network interface card which supports SR-IOV. Use thelspci
command to verify if the device was detected.# lspci 03:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
Note
Note that the output has been modified to remove all other devices.Start the SR-IOV kernel modules
If the device is supported the driver kernel module should be loaded automatically by the kernel. Optional parameters can be passed to the module using themodprobe
command. The Intel 82576 network interface card uses theigb
driver kernel module.# modprobe igb [<option>=<VAL1>,<VAL2>,] # lsmod |grep igb igb 87592 0 dca 6708 1 igb
Activate Virtual Functions
Themax_vfs
parameter of theigb
module allocates the maximum number of Virtual Functions. Themax_vfs
parameter causes the driver to spawn, up to the value of the parameter in, Virtual Functions. For this particular card the valid range is0
to7
.Remove the module to change the variable.# modprobe -r igb
Restart the module with themax_vfs
set to1
or any number of Virtual Functions up to the maximum supported by your device.# modprobe igb max_vfs=1
Inspect the new Virtual Functions
Using thelspci
command, list the newly added Virtual Functions attached to the Intel 82576 network device.# lspci | grep 82576 03:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:10.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 03:10.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
The identifier for the PCI device is found with the-n
parameter of thelspci
command.# lspci -n | grep 03:00.0 03:00.0 0200: 8086:10c9 (rev 01) # lspci -n | grep 03:10.0 03:10.0 0200: 8086:10ca (rev 01)
The Physical Function corresponds to8086:10c9
and the Virtual Function to8086:10ca
.Find the devices with virsh
The libvirt service must find the device to add a device to a guest. Use thevirsh nodedev-list
command to list available host devices.# virsh nodedev-list | grep 8086 pci_8086_10c9 pci_8086_10c9_0 pci_8086_10ca pci_8086_10ca_0 [output truncated]
The serial numbers for the Virtual Functions and Physical Functions should be in the list.Get advanced details
Thepci_8086_10c9
is one of the Physical Functions andpci_8086_10ca_0
is the first corresponding Virtual Function for that Physical Function. Use thevirsh nodedev-dumpxml
command to get advanced output for both devices.# virsh nodedev-dumpxml pci_8086_10ca # virsh nodedev-dumpxml pci_8086_10ca_0 <device> <name>pci_8086_10ca_0</name> <parent>pci_8086_3408</parent> <driver> <name>igbvf</name> </driver> <capability type='pci'> <domain>0</domain> <bus>3</bus> <slot>16</slot> <function>1</function> <product id='0x10ca'>82576 Virtual Function</product> <vendor id='0x8086'>Intel Corporation</vendor> </capability> </device>
This example adds the Virtual Functionpci_8086_10ca_0
to the guest in Step 8. Note thebus
,slot
andfunction
parameters of the Virtual Function, these are required for adding the device.Add the Virtual Function to the guest
- Shut down the guest.
- Use the output from the
virsh nodedev-dumpxml pci_8086_10ca_0
command to calculate the values for the configuration file. Convert slot and function values to hexadecimal values (from decimal) to get the PCI bus addresses. Append "0x" to the beginning of the output to tell the computer that the value is a hexadecimal number.The example device has the following values: bus = 3, slot = 16 and function = 1. Use theprintf
utility to convert decimal values to hexadecimal values.$ printf %x 3 3 $ printf %x 16 10 $ printf %x 1 1
This example would use the following values in the configuration file:bus='0x03' slot='0x10' function='0x01'
- Open the XML configuration file with the
virsh edit
command. This example edits a guest named MyGuest.# virsh edit MyGuest
- The default text editor will open the libvirt configuration file for the guest. Add the new device to the
devices
section of the XML configuration file.<hostdev mode='subsystem' type='pci' managed='yes'> <source> <address bus='0x03' slot='0x10' function='0x01'/> </source> </hostdev>
- Save the configuration.
Restart
Restart the guest to complete the installation.# virsh start MyGuest
The guest should start successfully and detect a new network interface card. This new card is the Virtual Function of the SR-IOV device.