Skip to content

kvm: give virtual router NICs one queue per vCPU - #22

Open
calvix wants to merge 2 commits into
integration/all-fixes-4.23.0.0from
fix/kvm-router-nic-multiqueue-4.23
Open

calvix wants to merge 2 commits into
integration/all-fixes-4.23.0.0from
fix/kvm-router-nic-multiqueue-4.23

Conversation

@calvix

@calvix calvix commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Virtual router NICs on KVM get a single virtio queue, so all traffic of a router with several vCPUs is handled by one host vhost thread. Router NICs now get one queue per vCPU, when the router is defined, when a NIC is hot-plugged and when it is replugged after a VLAN or physical network change; queue settings from the VM details still win. Guest VM NICs are not changed, and only the router's NIC plug reads the domain's vCPU count.

The behaviour can be switched off per host with the agent property router.nic.multiqueue.enabled (default true), documented in agent.properties. Packed virtqueues are not used: the kernel's vhost-net does not offer the packed ring, so the guest would use the split ring anyway. Unit tests cover the router, single-vCPU, guest VM, VM detail and switched-off cases, and the plug and replug wrappers.

A virtual router's virtio NICs always have a single queue: VPC router NICs
are hot-plugged with an empty details map, and the agent cannot resolve
nic.multiqueue.number=-1 on a plugged NIC because it gets no vCPU count. One
host vhost thread then copies every packet of the NIC and caps the router's
throughput whatever its vCPU count.

For VMs of type DomainRouter, every virtio NIC now gets queues=<vCPUs> (from
2 vCPUs up) and packed virtqueues (where QEMU and libvirt support them), both
when the domain is defined and when a NIC is hot-plugged; the plug path reads
the vCPU count from the running domain. Queue settings from the VM details
still win. The agent property router.nic.multiqueue.enabled (default true)
switches it off.
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

…plug

Packed virtqueues were asked for on router NICs to cut the vhost thread's
per-packet cost, but the kernel's vhost-net does not offer the packed ring:
QEMU runs the NIC with packed=true, yet the device does not offer
VIRTIO_F_RING_PACKED to the guest (checked with x-query-virtio-status on
QEMU 10.2.1, kernel 7.0). The guest always uses the split ring, so packed is
dropped and router NICs get multiqueue only.

- A replugged router NIC, after a VLAN or physical network change, keeps one
  queue per vCPU instead of falling back to a single queue.
- Plugging a NIC reads the domain's vCPU count only for routers, so a failure
  there cannot fail the plug of another VM's NIC.
@calvix calvix changed the title kvm: give virtual router NICs one queue per vCPU and packed virtqueues kvm: give virtual router NICs one queue per vCPU Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant