Skip to content

Feat/vfio user - #488

Open
Lencerf wants to merge 8 commits into
google:mainfrom
Lencerf:feat/vfio-user
Open

Feat/vfio user#488
Lencerf wants to merge 8 commits into
google:mainfrom
Lencerf:feat/vfio-user

Conversation

@Lencerf

@Lencerf Lencerf commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Assisted-by: Antigravity:Gemini-3.7-Flash
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Assisted-by: Antigravity:Gemini-3.7-Flash
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Define structs and constants for vfio-user messages using consts! and
bitflags! macros. Implement zerocopy traits for serialization.

TAG=agy
CONV=563b5413-8af4-45cc-a898-1abde6e4000b
Remove raw File descriptor dependency from Device trait to allow
userspace implementations (like vfio-user). Split multiplexed set_irqs
into higher-level methods.

Introduce VfioIoDevice to share host kernel VFIO device logic between
cdev and group backends, and cache regions to avoid per-access ioctls on
the MMIO hot path.

TAG=agy
CONV=563b5413-8af4-45cc-a898-1abde6e4000b
Implement VfioUserSession wrapping a UnixStream. Handle request-reply
transacts, optional FD passing (using SCM_RIGHTS), version negotiation,
and DMA map/unmap protocol requests.

Ensure header reads are fragmentation-safe by looping with read_exact
if needed. Validate reply message size to prevent underflows. Implement
race-free non-zero msg_id allocation.

TAG=agy
CONV=563b5413-8af4-45cc-a898-1abde6e4000b
…rDevice

Create VfioUserDevice struct wrapping VfioUserSession. Implement the
abstract Device trait to route guest accesses, IRQ settings, and reset
commands. Implement UpdateVfioUserMapping (LayoutChanged callback) to
sync DMA mappings.

Optimize read_region to use a stack buffer for small reads (avoiding heap
allocations on the MMIO hot path). Use zerocopy::read_from_prefix
instead of unsafe casts. Add safety comments and debug asserts.

TAG=agy
CONV=563b5413-8af4-45cc-a898-1abde6e4000b
Implement add_vfio_user_dev in Machine to connect, negotiate version,
register DMA callback, and register VfioPciDev. Update CLI configuration
and boot parsing to expose --vfio-user socket=<path> command line flag.

Register memory change callback after successful device addition to
prevent leaking open sockets on failure.

TAG=agy
CONV=563b5413-8af4-45cc-a898-1abde6e4000b
Assisted-by: Antigravity:Gemini-3.7-Flash
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 33362774183

Coverage increased (+7.1%) to 38.977%

Details

  • Coverage increased (+7.1%) from the base build.
  • Patch coverage: 133 uncovered changes across 8 files (644 of 777 lines covered, 82.88%).
  • 2 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
alioth/src/vfio/user/conn.rs 172 123 71.51%
alioth/src/vfio/user/device.rs 297 256 86.2%
alioth/src/vm/vm.rs 16 0 0.0%
alioth/src/vfio/device.rs 88 80 90.91%
alioth/src/vfio/cdev.rs 42 36 85.71%
alioth/src/vfio/pci.rs 120 114 95.0%
alioth-cli/src/boot/boot.rs 5 1 20.0%
alioth/src/vfio/group.rs 37 34 91.89%

Coverage Regressions

2 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
alioth/src/vfio/pci.rs 2 89.59%

Coverage Stats

Coverage Status
Relevant Lines: 15483
Covered Lines: 5882
Line Coverage: 37.99%
Relevant Branches: 1568
Covered Branches: 764
Branch Coverage: 48.72%
Branches in Coverage %: Yes
Coverage Strength: 45.92 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants