Enable Intel VT-d in BIOS and in the kernel
Verify support
lspci
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)
Start the SR-IOV kernel modules
modprobe
command. The Intel 82576 network interface card uses the igb
driver kernel module.
# modprobe igb [<option>=<VAL1>,<VAL2>,] # lsmod |grep igb igb 87592 0 dca 6708 1 igb
Activate Virtual Functions
max_vfs
parameter of the igb
module allocates the maximum number of Virtual Functions. The max_vfs
parameter causes the driver to spawn, up to the value of the parameter in, Virtual Functions. For this particular card the valid range is 0
to 7
.
# modprobe -r igb
max_vfs
set to 1
or any number of Virtual Functions up to the maximum supported by your device.
# modprobe igb max_vfs=7
Make the Virtual Functions persistent
modprobe
command /etc/modprobe.d/igb.conf options igb max_vfs=7
Inspect the new Virtual Functions
lspci
command, list the newly added Virtual Functions attached to the Intel 82576 network device.
# lspci | grep 82576 0b:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 0b:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 0b:10.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:10.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:10.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:10.3 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:10.4 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:10.5 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:10.6 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:10.7 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:11.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:11.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:11.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:11.3 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:11.4 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 0b:11.5 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
-n
parameter of the lspci
command. The Physical Functions corresponds to 0b:00.0
and 0b:00.1
. All the Virtual Functions have Virtual Function
in the description.
Verify devices exist with virsh
libvirt
service must recognize the device before adding a device to a guest. libvirt
uses a similar notation to the lspci
output. All punctuation characters, ; and ., in lspci output are changed to underscores (_).
virsh nodedev-list
command and the grep command to filter the Intel 82576 network device from the list of available host devices. 0b
is the filter for the Intel 82576 network devices in this example. This may vary for your system and may result in additional devices.
# virsh nodedev-list | grep 0b
pci_0000_0b_00_0
pci_0000_0b_00_1
pci_0000_0b_10_0
pci_0000_0b_10_1
pci_0000_0b_10_2
pci_0000_0b_10_3
pci_0000_0b_10_4
pci_0000_0b_10_5
pci_0000_0b_10_6
pci_0000_0b_11_7
pci_0000_0b_11_1
pci_0000_0b_11_2
pci_0000_0b_11_3
pci_0000_0b_11_4
pci_0000_0b_11_5
Get device details with virsh
pci_0000_0b_00_0
is one of the Physical Functions and pci_0000_0b_10_0
is the first corresponding Virtual Function for that Physical Function. Use the virsh nodedev-dumpxml
command to get advanced output for both devices.
<device> <name>pci_0000_0b_00_0</name> <parent>pci_0000_00_01_0</parent> <driver> <name>igb</name> </driver> <capability type='pci'> <domain>0</domain> <bus>11</bus> <slot>0</slot> <function>0</function> <product id='0x10c9'>Intel Corporation</product> <vendor id='0x8086'>82576 Gigabit Network Connection</vendor> </capability> </device> # virsh nodedev-dumpxml pci_0000_0b_10_0 <device> <name>pci_0000_0b_10_0</name> <parent>pci_0000_00_01_0</parent> <driver> <name>igbvf</name> </driver> <capability type='pci'> <domain>0</domain> <bus>11</bus> <slot>16</slot> <function>0</function> <product id='0x10ca'>Intel Corporation</product> <vendor id='0x8086'>82576 Virtual Function</vendor> </capability> </device>
pci_0000_0b_10_0
to the guest in Step 10. Note the bus
, slot
and function
parameters of the Virtual Function, these are required for adding the device.
Detach the Virtual Functions
# virsh nodedev-dettach pci_0000_0b_10_0 Device pci_0000_0b_10_0 dettached
Add the Virtual Function to the guest
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.
printf
utility to convert decimal values to hexadecimal values.
$ printf %x 3 3 $ printf %x 16 10 $ printf %x 1 1
bus='0x03' slot='0x10' function='0x01'
virsh edit
command. This example edits a guest named MyGuest
.
# virsh edit MyGuest
devices
section of the XML configuration file.
<hostdev mode='subsystem' type='pci'> <source> <address bus='0x03' slot='0x10' function='0x01'/> </source> </hostdev>
Restart
# virsh start MyGuest