Feat/vfio user - #488
Open
Lencerf wants to merge 8 commits into
Open
Conversation
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>
Coverage Report for CI Build 33362774183Coverage increased (+7.1%) to 38.977%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.