Skip to content

vfio-ioctls: Support pre-bound iommufd cdev fds#153

Merged
likebreath merged 4 commits into
rust-vmm:mainfrom
likebreath:0506/accept_iommufd_fd
May 22, 2026
Merged

vfio-ioctls: Support pre-bound iommufd cdev fds#153
likebreath merged 4 commits into
rust-vmm:mainfrom
likebreath:0506/accept_iommufd_fd

Conversation

@likebreath
Copy link
Copy Markdown
Collaborator

@likebreath likebreath commented May 21, 2026

Summary of the PR

Adds VfioDevice::new_from_bound_fd for callers that own the iommufd
lifecycle and pass in a cdev file that is already bound to an iommufd.
Useful when the bind state must outlive the VfioDevice.

Commits:

  • vfio-ioctls: Split bind/attach helpers for cdev mode — refactor
    cdev setup so bind and attach can be invoked independently.
  • vfio-ioctls: Bump to iommufd-ioctls v0.2.0 — pick up APIs needed
    for the pre-bound path.
  • vfio-ioctls: Add VfioDevice::new_from_bound_fd — new constructor
    that takes an already-bound cdev fd plus the caller's iommufd and
    IOAS, and only does the attach step.
  • vfio-ioctls: Destroy owned IOAS on VfioIommufd drop — only the
    owning VfioIommufd destroys the IOAS; externally provided ones
    are left to the caller.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

Assisted-by: Claude:Opus-4.7
Signed-off-by: Bo Chen <bchen@crusoe.ai>
Signed-off-by: Bo Chen <bchen@crusoe.ai>
New constructor for cdev files whose iommufd bind state is meant
to outlive the `VfioDevice`, e.g. for use cases where the caller
has a cdev file that is already bound to the iommufd.

Assisted-by: Claude:Opus-4.7
Signed-off-by: Bo Chen <bchen@crusoe.ai>
@likebreath likebreath force-pushed the 0506/accept_iommufd_fd branch from 987691f to 8d8b8eb Compare May 21, 2026 00:52
@likebreath likebreath marked this pull request as ready for review May 21, 2026 00:54
@likebreath
Copy link
Copy Markdown
Collaborator Author

@rbradford @sboeuf PTAL. Thank you.

Heads-up: this is the final change needed from the vfio crates to support VFIO live migration and accepting VFIO device fds in Cloud Hypervisor. I'm planning to cut a vfio-ioctls release once this lands.

Comment thread vfio-ioctls/src/vfio_device.rs Outdated
Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs Outdated
Comment thread vfio-ioctls/Cargo.toml
Assisted-by: Claude:Opus-4.7
Signed-off-by: Bo Chen <bchen@crusoe.ai>
@likebreath likebreath force-pushed the 0506/accept_iommufd_fd branch from 8d8b8eb to a4ace80 Compare May 21, 2026 17:03
@likebreath likebreath merged commit 5b77384 into rust-vmm:main May 22, 2026
8 checks passed
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.

4 participants