Skip to content

Conversation

@likebreath
Copy link
Member

The iommufd workspace hosts libraries related to Rust bindings and wrappers to the IOMMUFD subsystem
from the Linux kernel. It currently consists of the following crates:

  • iommufd-bindings -> Rust FFI bindings to IOMMUFD generated using bindgen
  • iommufd-ioctls -> Safe wrappers over IOMMUFD uAPIs

These crates will be used by the vfio-ioctls crate and also Cloud Hypervisor to support the new vfio cdev mode [1].

[1] rust-vmm/vfio#92

@likebreath
Copy link
Member Author

@up2wing @rbradford @liuw I think you might be interested. Please take a look. Thank you.

Copy link
Member

@liuw liuw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring the bindings, the code itself is just provides very simple wrappers.

It looks to me the destroy function is missing.

description = "Safe wrappers over IOMMUFD uAPIs"
repository = "https://github.com/cloud-hypervisor/iommufd"
readme = "README.md"
edition = "2021"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to stay on the 2021 edition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout. Updating it to 2024 edition.

@rbradford
Copy link
Member

sgtm - probably want to setup some basic GH workflows to compile and cross compile for the usual suspects - can probably just copy acpi_tables verbatim:

https://github.com/rust-vmm/acpi_tables/blob/main/.github/workflows/quality.yaml
https://github.com/rust-vmm/acpi_tables/blob/main/.github/workflows/dco.yaml
https://github.com/rust-vmm/acpi_tables/blob/main/.github/workflows/tests.yaml

Might need to add --workspace or something to handle that there are multiple crates here.

@up2wing
Copy link

up2wing commented Nov 16, 2025

Thanks a lot for letting me know.

I suppose this is a great start, we can do a lot from here on.


[dependencies]
iommufd-bindings = { version = "0.1.0", path = "../iommufd-bindings" }
thiserror = "1.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thiserror in the main code version is 2.0.17, how about keep it consistent?

// and we verify the return value.
let ret = unsafe { ioctl_with_ref(iommufd, IOMMU_IOAS_UNMAP(), unmap) };
if ret < 0 {
Err(IommufdError::IommuIoasAlloc(SysError::last()))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IommufdError::IommuIoasMap/Unmap seems to be more clearly.

@likebreath
Copy link
Member Author

likebreath commented Nov 17, 2025

Ignoring the bindings, the code itself is just provides very simple wrappers.

Right, that's my intention. I want to start with minimum and gradually extend based on what we need. The kernel interfaces are also not fully settled yet.

For supporting vfio cdev, that's all what we need from iommufd. To support accelerated IOMMU and shared virtual addressing in the guest, we will need more and let's add them later.

It looks to me the destroy function is missing.

We don't need it for now. Since no dynamic iommufd resource management is involved, we simply rely that all iommufd objects will be "destroyed" when the corresponding iommufd handle is closed.

@likebreath
Copy link
Member Author

Thank you all for the fast turn around. I will address these comments later this week.

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