Skip to content

qemu-ntb: Plan

Strategy (c): first a prototype that runs outside QEMU, over vfio-user; once the system is shown to work, a device inside QEMU, from the same specification.

References point to the recommendations R1–R16 in LITERATURE.md.

Architecture (prototype)

 VM A (QEMU, vfio-user client)             VM B (QEMU, vfio-user client)
   guest: ntb_hw_qntb + ntb_transport        guest: ntb_hw_qntb + ntb_transport
            |  vfio-user socket A                      |  vfio-user socket B
            +---------------> ntbd <-------------------+
                 (one process, libvfio-user, two device instances,
                  shared state: link, spads, doorbells, MW translation, DMA)
  • One process, two ends: ntbd opens two vfio-user servers and gives one device to each VM. Since both sides live in the same process, the first version needs no protocol between the two servers. The peer protocol (R6) is designed separately for the QEMU-internal device and tried in the prototype in a second stage.
  • Guest memory: QEMU is started with memory-backend-memfd,share=on. The vfio-user client passes the fds of the DMA regions to the server, so ntbd can access the RAM of both guests directly.
  • Outbound MW: in v0 BAR accesses are trapped (each access is a socket round trip: slow but correct). ntbd writes the address into the peer guest RAM through the peer's inbound translation. This is the R7b approach and is also the right path for ntb_msi (MSI injection into the peer is handled separately).
  • DMA engine (R9): the bulk data path. ntbd copies directly from its own guest's RAM into the peer guest's RAM. The real performance of ntb_transport use_dma=1 comes from here.
  • Fast outbound path (R7a): a v1 goal. That vfio-user region mmaps cannot be changed dynamically may be an obstacle; to be investigated.

Register model

Written in docs/SPEC.md. Starting point R1–R5: direct registers (no command/polling interface), BAR0 control, MW BARs, 16 spads, 32 doorbells, MSI-X, inbound translation only, development PCI ID 1af4:10fx. The specification is the single source for both ntbd and the later QEMU-internal device.

Milestones

# Work Acceptance criterion
P0 Environment: QEMU (a version with the vfio-user client) and libvfio-user from source, guest kernel (NTB modules enabled), two-VM scripts Two VMs boot; a sample libvfio-user device (e.g. gpio-pci-idio-16) shows up in the guest
P1 docs/SPEC.md: register map, BAR layout, IRQs, link state machine, DMA descriptor format Reviewed specification; every mandatory ntb_dev_ops op is mapped to a register
P2 ntbd v0: link, spads, doorbells, MSI-X, MW (trapped) Spad/doorbell/MW read-write with ntb_tool in the guest; the ntb_pingpong counter increases
P3 Linux ntb_hw_qntb driver, all mandatory ops + spads + mw_clear_trans (R13, R14) ntb_transport + ntb_netdev: ping and iperf3 between two VMs
P4 DMA engine + dmaengine provider (R9, R10) ntb_perf use_dma=1 and ntb_transport use_dma=1 work; measurement table with/without DMA
P5 Tests: own register tests, selftests/ntb/ntb_test.sh, CI script (R15) One command sets up two VMs and runs all tests
P6 ntb_msi, fast outbound path (R7a), migration blocker (R12) ntb_msi_test passes; R7a vs R7b measurement
P7 QEMU-internal device qntb (qemu/hw/misc/qntb.c, built into a patched QEMU 11.1.3 by scripts/build-qemu.sh); peer protocol (R6) See P7a–P7c
P7a Device with the message path (R7b), migration blocker All run-all.sh tests pass with NTB_IMPL=qemu; migrate is refused
P7b MSI forwarding (MSI_FWD = 1, msix_get_message) ntb_msi_test registers > 0 interrupts
P7c Fast MW path (R7a, shared memory mapping) ntb_netdev without DMA measurably faster; R7a/R7b table in docs/
1.0 Close the P5 test debt (flood, forced link drop, 64-bit doorbell), LICENSE, README/SETUP for both implementations run-all.sh green with both implementations
## Rules
  • The QEMU-internal device is not part of upstream QEMU. The repository ships only the device source and a small build patch, not a QEMU tree.
  • Third-party sources (QEMU, libvfio-user, kernel) are downloaded into a separate directory, signatures/hashes are verified, and the source trees are not modified.
  • Performance claims are written down only if measured.

Users of this repository (decided 2026-11-26)

In this order, after P7: 1. ntb-lab (started 2026-11-27): two Linux VMs on the qntb device with tests, and a generic Linux NTB client module (ntb_seg: mmap of the inbound and outbound windows, doorbells, DMA) that works on any Linux NTB hardware driver. First version: module, segtool, a two-VM test that passes with both implementations, tutorial and API reference. 2. pushseg: a new ntb mapped backend on top of ntb_seg. Done (2026-11-27), tested between the VMs by ntb-lab's t-pushseg.sh. 3. gridlane: the demonstrator over pushseg's ntb backend, compared with TCP. Done (2026-11-27): ntb-lab's t-gridlane.sh, data plane on NTB, control plane on TCP over a second NTB link; agrees with the reference.

Open points

  • In which version the QEMU vfio-user client landed, and how guest RAM fd sharing (DMA regions) works, is verified in P0.
  • Performance of exposing the outbound BAR as trapped MMIO; acceptable for v0, R7a in v1.
  • How to inject MSIs into the peer guest (ntb_msi) over vfio-user.