Skip to content

iommufd-ioctls: Open the iommufd from a caller-provided path - #16

Closed
Lencerf wants to merge 1 commit into
cloud-hypervisor:mainfrom
Lencerf:iommufd-custom-path
Closed

Lencerf wants to merge 1 commit into
cloud-hypervisor:mainfrom
Lencerf:iommufd-custom-path

Conversation

@Lencerf

@Lencerf Lencerf commented Nov 4, 2026

Copy link
Copy Markdown

IommuFd::new() hardcodes /dev/iommu, which does not work in environments where device nodes are exposed at a different location, such as sandboxes or containers that remap /dev. new_from_fd() covers the case where the caller opens the device itself, but it does not help when the VMM is the one expected to open it.

Add IommuFd::new_from_path() to open the iommufd character device at an arbitrary path, and make new() a thin wrapper around it opening /dev/iommu. Drop the hardcoded path from the OpenIommufd error message since the source error already carries the failing path.

`IommuFd::new()` hardcodes `/dev/iommu`, which does not work in
environments where device nodes are exposed at a different location,
such as sandboxes or containers that remap `/dev`. `new_from_fd()`
covers the case where the caller opens the device itself, but it does
not help when the VMM is the one expected to open it.

Add `IommuFd::new_from_path()` to open the iommufd character device at
an arbitrary path, and make `new()` a thin wrapper around it opening
`/dev/iommu`. Drop the hardcoded path from the `OpenIommufd` error
message since the source error already carries the failing path.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
@Lencerf
Lencerf marked this pull request as draft November 4, 2026 17:30
@Lencerf Lencerf closed this Nov 4, 2026
@Lencerf
Lencerf deleted the iommufd-custom-path branch November 4, 2026 17:36
@Lencerf

Lencerf commented Nov 4, 2026

Copy link
Copy Markdown
Author

Dropping this PR as I realized the caller can open iommufd char device file and then call Iommufd:: new_from_fd.

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.

1 participant