Skip to content

Running driver tests on virtio

Jakub K edited this page May 7, 2025 · 1 revision

Please refer to Running driver tests for general instructions. This section covers just the virtio related aspects.

External loopback

The tests need 2 "NICs" so they require 2 multi-queue tap devices connected with a bridge. See the setup_net.sh script for how such loop is set up on the worker. The script has a loop because it sets up 4 runner instances, since runner only needs one pair of taps and one bridge.

qemu options

Following QEMU options are needed to add the 2 virtio interfaces:

-device virtio-net-pci,netdev=n0,iommu_platform=on,disable-legacy=on,mq=on,vectors=18 \
-netdev tap,id=n0,ifname=tap0,vhost=on,script=no,downscript=no,queues=8 \
-device virtio-net-pci,netdev=n1,iommu_platform=on,disable-legacy=on,mq=on,vectors=18 \
-netdev tap,id=n1,ifname=tap1,vhost=on,script=no,downscript=no,queues=8

When using vng use -o ' -device virtio-net-pci ... (not the space before the option).

In-VM setup

Source vm-virtio-loop.sh inside the VM to setup the env. It will move one of the virtio interfaces to a netns and add IP addresses. The script needs to be sourced (source /path/to/vm-virtio-loop.sh) because it will export the env variables like NETIF which the tests will need.

After the script is sourced all driver tests executed in the same terminal should run against virtio.