Skip to main content

VirtioPciDeviceBuilder

Struct VirtioPciDeviceBuilder 

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

Builder pattern instantiation for VirtioPciDevice.

The builder implements virtio initialization. This is a multi-step process because it mixes logic specific to each virtio device type with logic applicable to all devices that use the PCI transport.

Implementations§

Source§

impl VirtioPciDeviceBuilder

Source

pub async fn new( pci: ClientEnd<Device>, ) -> Result<VirtioPciDeviceBuilder, Status>

Returns a builder ready for feature bits negotiation.

See [offered_features()] for the next initialization step.

Source

pub fn offered_features(&self) -> VirtioFeatureBits

Returns the features offered by the device.

Use the result to compute device type-specific accepted features, and then call [accept_features()].

Source

pub async fn accept_features( &mut self, accepted_features: VirtioFeatureBits, ) -> Result<(), Status>

Leaves the virtio device ready for device type-specific initialization.

accepted_features must be a subset of the bits returned by [offered_features()].

After this method succeeds, perform device-specific initialization and then call [build()].

The directions above entail that the method completes feature negotiation, performs transport-specific initialization, and automatically configures all discovered virtqueues.

On failure, sets DeviceStatus::driver_terminated to true, signaling that the driver will abandon this device.

Source

pub fn bti(&self) -> &Bti

Returns a BTI that can pin VMOs in device-addressable memory.

Intended to be used during device type-specific initialization.

Source

pub fn take_device_configuration(&mut self) -> Option<MmioRegion<VmoMemory>>

Returns the memory area that holds device-specific configuration.

The device must present at least one [PciCapabilityType::DEVICE_CONFIGURATION] capability for any device type that has a device type-specific configuration.

Returns None if the device does not expose any device-specific configuration, or if the method is called more than once.

Source

pub fn build(self) -> Result<VirtioPciDevice, Status>

Consumes the builder and produces an initialized device.

Must be called after device-specific initialization is completed, which must follow a successful call to [accept_features()].

On failure, sets DeviceStatus::driver_terminated to true, signaling that the driver will abandon this device.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> InstanceFromServiceTransport<T> for T

§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to [Self]
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<E> RunsTransport<Mpsc> for E

§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.