3.4. Assigning SR-IOV VF Network Adapter to Linux KVM VM

We have a virtual machine running CentOS 7. This virtual machine already has a primary network interface with IP address 192.168.0.223. Our goal is to assign a function network interface created previously to this running CentOS 7 virtual machine.

We have identified the new virtual function network adapter as enp37s16 and can see that it appears as an available network interface on our hypervisor.

../_images/vhs7-asrock-41.png

Now, let’s see how to pass through this network virtual function to a virtual machine in a persistent way.

  1. We will be using the Bus info in the next steps. However, you need to replace “:” and “@” with “_” when querying the device. For example, pci@0000:25:10:0 >> pci_0000_25_10_0.

    ../_images/vhs7-asrock-40-42.png
  2. Gather information about the VF network adapter. Use virsh and the pci address in the format from the previous step.

    # virsh nodedev_dumpxml pci_0000_25_10_0
    
    ../_images/vhs7-asrock-43.png
  3. Using the information highlighted in the image from the previous step, create an xml file to define the network interface.

    [root@vhs ~]# vim /tmp/vf.xml
    
    ../_images/vhs7-asrock-44.png

    Attach the device using virsh. You can use the following flags:

    • –live - attach the interface to the running virtual machine

    • –persistent - use this network interface definition for future guest reboots (it doesn’t persist on host reboots)

    • –config - apply the changes after VM reboot

    ../_images/vhs7-asrock-45.png

    Verify that the device has been attached to the virtual machine correctly.

    ../_images/vhs7-asrock-46.png
  4. We have attached a virtual function network card to the virtual machine as a secondary network NIC. Let’s see the status of the network interfaces on the virtual machine before assigning the device.

    ../_images/vhs7-asrock-47.png
  5. After assigning the device, we can see the new virtual function network adapter inside the virtual machine at the guest layer.

    ../_images/vhs7-asrock-48.png

That’s all! Now, you can proceed with network interface configuration as in any regular virtual machine.