16.2. Using SR-IOV
Important
/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.
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 thelspcicommand to verify if the device was detected.lspci
# 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)Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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 themodprobecommand. The Intel 82576 network interface card uses theigbdriver kernel module.modprobe igb [<option>=<VAL1>,<VAL2>,] lsmod |grep igb
# modprobe igb [<option>=<VAL1>,<VAL2>,] # lsmod |grep igb igb 87592 0 dca 6708 1 igbCopy to Clipboard Copied! Toggle word wrap Toggle overflow Activate Virtual Functions
Themax_vfsparameter of theigbmodule allocates the maximum number of Virtual Functions. Themax_vfsparameter causes the driver to spawn, up to the value of the parameter in, Virtual Functions. For this particular card the valid range is0to7.Remove the module to change the variable.modprobe -r igb
# modprobe -r igbCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the module with themax_vfsset to1or any number of Virtual Functions up to the maximum supported by your device.modprobe igb max_vfs=1
# modprobe igb max_vfs=1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Inspect the new Virtual Functions
Using thelspcicommand, list the newly added Virtual Functions attached to the Intel 82576 network device.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The identifier for the PCI device is found with the-nparameter of thelspcicommand.The Physical Function corresponds tolspci -n | grep 03:00.0 lspci -n | grep 03:10.0
# 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)Copy to Clipboard Copied! Toggle word wrap Toggle overflow 8086:10c9and 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-listcommand to list available host devices.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The serial numbers for the Virtual Functions and Physical Functions should be in the list.Get advanced details
Thepci_8086_10c9is one of the Physical Functions andpci_8086_10ca_0is the first corresponding Virtual Function for that Physical Function. Use thevirsh nodedev-dumpxmlcommand to get advanced output for both devices.Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example adds the Virtual Functionpci_8086_10ca_0to the guest in Step 8. Note thebus,slotandfunctionparameters 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_0command 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 theprintfutility to convert decimal values to hexadecimal values.Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example would use the following values in the configuration file:bus='0x03' slot='0x10' function='0x01'
bus='0x03' slot='0x10' function='0x01'Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the XML configuration file with the
virsh editcommand. This example edits a guest named MyGuest.virsh edit MyGuest
# virsh edit MyGuestCopy to Clipboard Copied! Toggle word wrap Toggle overflow - The default text editor will open the libvirt configuration file for the guest. Add the new device to the
devicessection of the XML configuration file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the configuration.
Restart
Restart the guest to complete the installation.virsh start MyGuest
# virsh start MyGuestCopy to Clipboard Copied! Toggle word wrap Toggle overflow