#876

virtio/net: add a passt vhost-user backend

Openkaruboniruwants to merge intofrom

Add vhost-user path and borrowed-FD constructors to NetDevice for Linux NET builds with a local MAC and one RX/TX queue pair. Reuse the vhost-user frontend and request shared guest RAM and kernel mappings through device requirements while preserving device ordering.

Filter network features, gate CONFIG and MQ requests on negotiated protocol support, and pass eventfds without transferring ownership. Include API/protocol tests, passt TCP/UDP integration tests, iperf test entries, generated bindings and usage documentation. Reject TEE and Nitro configurations.

Assisted-by: Codex: GPT-6


The idea was when I realized both passt socket and TSI are suffering from some strange performance issue, and a test with qemu showed significant better network performance so I wanted to try the same for libkrun.

performance test (unit in Gbps):

  • 7.2.7-300.fc45.x86_64 host kernel
  • 13700H CPU
  • 1 vCPU, 512 MiB RAM, one TCP stream per direction, 2-second warmup followed by 10 seconds of measurement,
  • TX/RX are from the guest's perspective
BackendTX onlyRX onlyBidir TXBidir RXBidir total
passt vhost-user23.4979.3018.4839.4257.91
passt socket23.5914.360.00*12.2312.23
TSI29.48Timeout*17.1817.6034.81

(note that when running bidir mode original options, incl. passt socket and TSI both have problem in sending)


Opening as draft RFC.

Activity

7
copilot-pull-request-reviewer[bot]reviewed1mo ago
copilot-pull-request-reviewer[bot]1mo ago

Copilot review overview

🔵 Needs a closer look

Broad, platform-specific vhost-user networking and memory changes require final human review.

Review effort: Lite
Findings: None

What changed in this PR

Adds Linux passt vhost-user networking with shared guest memory, borrowed-FD/path APIs, protocol negotiation, tests, and documentation.

Changes:

  • Adds vhost-user-backed network device constructors and C bindings.
  • Integrates shared memory, event handling, and virtio feature filtering.
  • Adds passt integration/performance tests and dependency updates.
FileDescription
tests/​test_cases/​src/​test_net/​passt_vhost_user.rsAdds passt vhost-user setup helpers.
tests/​test_cases/​src/​test_net/​mod.rsAdds network integration coverage.
tests/​test_cases/​src/​test_net_perf.rsAdds performance test cases.
tests/​test_cases/​src/​lib.rsRegisters new tests.
tests/​test_cases/​src/​common.rsUpdates required symbols.
tests/​Cargo.lockUpdates test dependencies.
src/​libkrun/​src/​vmm/​builder.rsEnables shared file-backed guest memory.
src/​libkrun/​src/​api/​device_builders.rsAdds vhost-user network APIs.
src/​devices/​src/​virtio/​vhost_user/​device.rsImplements vhost-user networking.
src/​devices/​src/​virtio/​mod.rsGates vhost-user support.
src/​devices/​Cargo.tomlUpdates device dependencies.
README.mdDocuments usage and limitations.
include/​libkrun.hDeclares new C APIs.
Cargo.lockUpdates workspace dependencies.
bindings/​libkrun-via-cdylib-weak/​ffier-krun.jsonUpdates generated FFI metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

copilot-pull-request-reviewer[bot]reviewed1mo ago
copilot-pull-request-reviewer[bot]1mo ago

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

copilot-pull-request-reviewer[bot]reviewed1mo ago
copilot-pull-request-reviewer[bot]1mo ago

Copilot review overview

🔵 Needs a closer look

CI enables passt tests without installing a passt build with vhost-user support, so the tests may be silently skipped.

Review effort: Lite
Findings: None

mtjhrc1mo ago

So the vhost-user-net passt is already supported without doing any changes to the builtin virtio-net backend you can just use the builtin vhost device. We may make it more user friendly but I would rather add a simplified constructor to VhostDevice rather than changing the net device.

https://github.com/mtjhrc/libkrun/blob/d1e443ecfcf2d3f2982c272b9450006a2fa9ebd9/tests/test_cases/src/test_net/vhost_user_passt.rs#L85-L104

I have a draft opened for adding the test: https://github.com/libkrun/libkrun/pull/784 but the feature already works on main branch.