Multi Channel DMA Intel® FPGA IP for PCI Express* Design Example User Guide

ID 683517
Date 7/30/2024
Public
Document Table of Contents

3.5.2.3.2.3. Enabling VFs and Create Guest VM by Using QEMU

Follow the steps below to create the guest environment and assign VF device to VM by using QEMU:
  1. Enable Virtual functions based on requirements:
    $ echo 2 > /sys/bus/pci/devices/<bdf>/max_vfs
  2. Install vfio-pci module

    $modprobe vfio-pci

  3. Bind the device to vfio-pci
    1. If the device is bound to ifc_uio, unbind with the following command:

      $ echo "<bdf>" > /sys/bus/pci/devices/<bdf>/driver/unbind

      E.g: echo "0000:01:00.0" > /sys/bus/pci/devices/0000\:01\:00.0/driver/unbind

    2. Bind the device to vfio-pci

      echo <PCI Vendor ID> <PCI Device ID> > /sys/bus/pci/drivers/vfio-pci/new_id

      Example: echo 1172 0000 > /sys/bus/pci/drivers/vfio-pci/new_id

  4. Use following parameters to start the Guest VM (on Intel machines, use QEMU version 3.0.0-rc0). Here, a minimum of 8 GB of memory needs to be allocated to VM.

    $ qemu-3.0.0-rc0/x86_64-softmmu/qemu-system-x86_64 -smp 2 -m 8192M -boot c -machine q35,kernel-irqchip=split -cpu host -enable-kvm -nographic -L /root/qemu-3.0.0-rc0/pc-bios -name offload1 -hda <path_to_qcow2_file> -device vfio-pci,host=<bdf> -netdev type=tap,id=net6551,script=no,downscript=no,vhost=on,ifname=net6551 -device virtio-net-pci,netdev=net6551 -device intel-iommu,intremap=on,caching-mode=on -serial telnet::5551,server,nowait -object memory-backend-file,id=mem,size=8192M,mem-path=/dev/hugepages,share=on -numa node,memdev=mem -mem-prealloc -monitor telnet::3331,server,nowait&

Note:
  1. On AMD machines, the parameter “-device intel-iommu,intremap=on,caching-mode=on” is not required.
  2. If multiple devices are in the same group, check for ACS enablement in the root port and bridge.
  3. Below are the Host and Guest VM configurations used for verification.
Table 42.  Host System Configuration
Host System Configuration Details
Operating System

CentOS Linux release 7.8

Ubuntu 22.04 LTS

Linux Kernel

CentOS: 3.10.0-1127.10.1.el7.28.x86_64

Ubuntu: 5.15.0-52-generic x86_64

CPU Cores 96
RAM 128 GB (64 GB on single NUMA)
Hypervisor KVM
QEMU Version QEMU version 3.0.0-rc0
Table 43.  Guest System Configuration
Host System Configuration Details
Operating System CentOS Linux release 7.8
Linux Kernel 3.10.0-1127.10.1.el7.28.x86_64
CPU Cores 2
RAM 8 GB