Virtualization

SR-IOV Explained: Near Bare-Metal Networking for Virtual Machines

By NileVPS Team · Published · 5 min read

اقرأ المقال بالعربي

Every packet that leaves a virtual machine has to cross a boundary between the guest and the physical network card. In a classic setup, that crossing is done in software: the hypervisor receives the packet, switches it through a virtual bridge, and hands it to the real NIC. It works well, but it costs CPU cycles and adds latency. Single Root I/O Virtualization, or SR-IOV, takes a different approach. It lets one physical network adapter present itself as many independent devices, so a VM can talk to the hardware almost directly. This article explains how SR-IOV works, where it shines, and why it is not the default for every cloud server.

How network I/O works without SR-IOV

In most KVM-based platforms, guests use a paravirtualized driver called virtio-net. The guest kernel places packets in shared memory rings, and a backend on the host (vhost-net in the kernel, or a userspace switch such as Open vSwitch with DPDK) picks them up and forwards them. This design is flexible: the host sees every packet, so it can apply firewall rules, rate limits, VLAN tagging, and accounting in one place. It also makes the VM completely independent of the physical hardware underneath.

The price is overhead. Each packet involves extra memory copies or at least extra processing on host CPU cores, plus notifications between guest and host. For a typical web server this is invisible. For workloads pushing millions of small packets per second, such as DNS resolvers, VoIP gateways, or high-frequency trading systems, it becomes the bottleneck.

What SR-IOV actually does

SR-IOV is a PCI Express specification published by PCI-SIG. A device that supports it exposes two kinds of functions.

Physical Function (PF)

The PF is the full-featured PCIe function. It is owned by the host, it has the complete configuration space, and its driver is responsible for managing the card: setting link speed, creating virtual functions, and assigning MAC addresses and VLANs to them.

Virtual Functions (VF)

VFs are lightweight PCIe functions created by the PF. Each VF has its own transmit and receive queues, its own MAC address, and its own PCI address, but it shares the physical port with the PF and other VFs. A modern server NIC can expose dozens or even hundreds of VFs. The hypervisor passes a VF straight into a VM using device passthrough, and the guest loads a VF driver (for example iavf for Intel or mlx5_core for NVIDIA/Mellanox cards).

Once that is done, the guest writes packets directly into the VF's hardware queues using DMA. The host CPU is no longer in the data path. The NIC's internal switch (often called the embedded switch or VEB) sorts traffic between VFs and the wire. Safe DMA from a guest relies on the IOMMU, which we cover in our IOMMU article.

Why VMs get near bare-metal performance

Because the guest owns a real hardware queue, SR-IOV removes most of the software layers between the application and the wire. In practice this delivers:

  • Lower latency, often within a few microseconds of bare metal.
  • Higher packet rates, since no host core is spent switching packets.
  • Less jitter, because the host scheduler no longer sits between your packets and the NIC.
  • Freed host CPU, which can be given back to guests as compute.

Throughput for large transfers was already good with virtio-net, so the biggest gains are in small-packet rates and tail latency.

The trade-offs

SR-IOV is not free, and the downsides explain why many providers use it selectively.

Live migration becomes hard

Live migration moves a running VM between hosts by copying its memory while it keeps running. With virtio, the device state lives in software and is easy to copy. With SR-IOV, part of the state lives inside a specific NIC on a specific host, and the hypervisor cannot simply snapshot it. Common workarounds include bonding a VF with a virtio interface inside the guest (failover mode, supported by the Linux net_failover driver) so traffic falls back to virtio during migration, or vendor-specific migration support that is still maturing. Without these, the VM must be stopped to move, which affects how the provider handles host maintenance.

Less host-side control

When packets bypass the host, so do host-side firewall rules and traffic shaping. Filtering has to be done in NIC hardware (MAC/VLAN anti-spoofing, rate limits per VF) or upstream in the network. Features like a cloud firewall then need careful design.

Hardware limits

The number of VFs per port is finite, the NIC and motherboard firmware must support SR-IOV, and the IOMMU must be enabled. Snapshots of the disk are unaffected, but anything tied to the NIC is less portable.

What this means for your VPS

Most general-purpose VPS plans, including standard instances you can launch from /deploy, use virtio-net because it gives the best balance of flexibility, firewall integration, and maintenance without downtime. You can check which driver your server uses:

# Show the driver behind your network interface
ethtool -i eth0

# List PCI devices; a VF shows up as "Virtual Function"
lspci | grep -i ethernet

# Check queue counts and offloads
ethtool -l eth0
ethtool -k eth0 | grep -E 'segmentation|checksum'

If ethtool -i reports virtio_net, you are on a paravirtualized interface. You can still tune it: enable multiqueue so packet processing spreads across vCPUs, and make sure irqbalance is running.

sudo ethtool -L eth0 combined $(nproc)
systemctl status irqbalance

On a host you control, enabling VFs looks like this:

cat /sys/class/net/enp1s0f0/device/sriov_totalvfs
echo 8 | sudo tee /sys/class/net/enp1s0f0/device/sriov_numvfs
ip link show enp1s0f0

Before reaching for SR-IOV, measure. Most web, database, and application workloads are limited by CPU, disk, or application code long before the virtual NIC.

FAQ

Is SR-IOV faster than virtio-net for every workload?

No. For bulk transfers and typical web traffic, a well-tuned virtio-net interface with multiqueue performs very close to SR-IOV. The difference shows up mainly in small-packet rates, microsecond-level latency, and jitter-sensitive applications.

Can I enable SR-IOV from inside my VPS?

No. SR-IOV is configured on the physical host by enabling the PF's virtual functions and passing them through to guests. A guest cannot create VFs. If a VF is assigned to you, it will appear as a PCI device and the matching driver will load automatically.

Does SR-IOV affect snapshots and backups?

Disk snapshots are independent of networking, so they keep working. What SR-IOV complicates is live migration and some host-level network features, because part of the VM's network state lives inside physical hardware rather than in software.

Related guides