Skip to content

qemu-ntb

A virtual PCIe NTB (Non-Transparent Bridge) for QEMU. Two VMs get what two hosts get from an NTB adapter: memory windows into each other's RAM, doorbells, scratchpads and a DMA engine. The Linux NTB stack runs on it unmodified.

docker run --rm -it --device /dev/kvm ghcr.io/oguzhankynk/qemu-ntb

Two VMs on one virtual NTB: VM a pings VM b, fetches a web page from it and sends 64 MiB with a matching checksum, all over ntb_netdev on the virtual NTB

Two VMs open side by side, with an IP network over the virtual NTB. No build needed; getting started has the other ways in.

flowchart LR
    subgraph A["VM A"]
        direction TB
        a1["ntb_transport, ntb_netdev, ..."] --- a2["ntb_hw_qntb"] --- a3["qntb (PCI device)"]
    end
    subgraph B["VM B"]
        direction TB
        b1["ntb_transport, ntb_netdev, ..."] --- b2["ntb_hw_qntb"] --- b3["qntb (PCI device)"]
    end
    a3 <-->|UNIX socket| b3

Why

NTB hardware is rare and hard to share. Without it you cannot run the Linux NTB clients, test a driver, or try a transport between two hosts. With qemu-ntb you can do all of that on a laptop, in CI, and with the kernel's bug detectors switched on.

What works

Linux client Result
ntb_tool all operations
ntb_pingpong works
ntb_transport + ntb_netdev ping and bulk transfers, with and without DMA
ntb_perf CPU and DMA paths
ntb_msi interrupts forwarded through a memory window
tools/testing/selftests/ntb/ntb_test.sh passes

Two implementations

QEMU device ntbd
What A PCI device built into QEMU (-device qntb) A vfio-user server for stock QEMU
QEMU 11.1.3 with a two-line build patch stock QEMU with the vfio-user client (tested: 11.1.3)
MSI forwarding (ntb_msi) yes no
CPU access to the peer through a window mapped directly (KVM, shared RAM) one message per access
Live migration blocked, as it should be not blocked (QEMU bug)

Both follow the same specification and pass the same tests. Use the QEMU device unless you cannot rebuild QEMU.

Next steps