Struct VfioContainer

Source
pub struct VfioContainer { /* private fields */ }
Expand description

A VFIO container representing an IOMMU context that may contain zero or more VFIO groups.

Implementations§

Source§

impl VfioContainer

Source

pub fn new(groups: &[u32]) -> Result<VfioContainer>

Creates a new, empty VfioContainer.

This fails if not all devices in all given groups have been bound to vfio-pci (the VFIO docs say “it’s also sufficient to only unbind the device from host drivers if a VFIO driver is unavailable”).

This fails if any of the groups is already open elsewhere, for instance if another VfioContainer containing one of the groups already currently exists.

Source

pub fn groups(&self) -> &[u32]

The group numbers of the groups this container contains.

In ascending order, without duplicates.

Source

pub fn iommu(&self) -> PciIommu<'_>

Returns a thing that lets you manage IOMMU mappings for DMA for all devices in all groups that belong to this container.

Source

pub fn reset(&self) -> Result<()>

Tries to reset all the PCI functions in all the VFIO groups that self refers to.

This requires that the user has “ownership” over all the affected functions / permissions to do it.

TODO: Reset granularity might not match container granularity. Will probably need to expose reset topology properly eventually.

TODO: Should probably advertise whether this granularity of reset is supported, so the user doesn’t have to try resetting to find out.

Trait Implementations§

Source§

impl Debug for VfioContainer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.