pub struct DmaMapperClient { /* private fields */ }Expand description
Client for registering DMA mappers with the region manager.
This is the public-facing handle for IOMMU consumers (VFIO, iommufd)
to register themselves. It exposes only add_dma_mapper, hiding the
rest of the region manager API.
Implementations§
Source§impl DmaMapperClient
impl DmaMapperClient
Sourcepub async fn add_dma_mapper(
&self,
target: Arc<dyn DmaTarget>,
needs_fd: bool,
) -> Result<DmaMapperHandle>
pub async fn add_dma_mapper( &self, target: Arc<dyn DmaTarget>, needs_fd: bool, ) -> Result<DmaMapperHandle>
Register a DMA target to receive sub-mapping events.
This may only be called in the same process as the region manager.
A host VA is always provided to DmaTarget::map_dma (the region
manager always maintains an eager VaMapper — handing out a VA is
free), so targets that program the IOMMU by VA (VFIO type1, iommufd)
need no special opt-in.
If needs_fd is true, the target additionally requires every mapping
to carry a backing fd. Such a target is incompatible with backing-less
mappings (private/anonymous RAM, exposed only by host VA): registration
fails if any such mapping already exists, and subsequent attempts to
create one fail. Use this for backends that must map from an fd (e.g., a
virtio-user frontend driven via the DMA mapper rather than the shared
guest-memory infrastructure).
The replay loop maps all existing active sub-mappings into the new
consumer. On failure, already-mapped entries are not rolled back;
the caller must clean up by dropping the DmaTarget (e.g., closing
the VFIO container fd).
Returns a DmaMapperHandle that removes the mapper when dropped.
Trait Implementations§
Source§impl Clone for DmaMapperClient
impl Clone for DmaMapperClient
Source§fn clone(&self) -> DmaMapperClient
fn clone(&self) -> DmaMapperClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more