Struct vhost::net::Net

source ·
pub struct Net<T> {
    descriptor: File,
    phantom: PhantomData<T>,
}
Expand description

Handle to run VHOST_NET ioctls.

This provides a simple wrapper around a VHOST_NET file descriptor and methods that safely run ioctls on that file descriptor.

Fields§

§descriptor: File§phantom: PhantomData<T>

Trait Implementations§

source§

impl<T> AsRawDescriptor for Net<T>

source§

fn as_raw_descriptor(&self) -> RawDescriptor

Returns the underlying raw descriptor. Read more
source§

impl<T> NetT<T> for Net<T>
where T: TapT,

source§

fn new(vhost_net_device_path: &Path) -> Result<Net<T>>

Opens /dev/vhost-net and holds a file descriptor open for it.

§Arguments
  • mem - Guest memory mapping.
source§

fn set_backend(&self, queue_index: usize, event: Option<&T>) -> Result<()>

Set the tap file descriptor that will serve as the VHOST_NET backend. This will start the vhost worker for the given queue. Read more
source§

impl<T> Vhost for Net<T>

source§

fn set_owner(&self) -> Result<()>

Set the current process as the owner of this file descriptor. This must be run before any other vhost ioctls.
source§

fn reset_owner(&self) -> Result<()>

Give up ownership and reset the device to default values. Allows a subsequent call to set_owner to succeed.
source§

fn get_features(&self) -> Result<u64>

Get a bitmask of supported virtio/vhost features.
source§

fn set_features(&self, features: u64) -> Result<()>

Inform the vhost subsystem which features to enable. This should be a subset of supported features from VHOST_GET_FEATURES. Read more
source§

fn set_mem_table(&self, mem: &GuestMemory) -> Result<()>

Set the guest memory mappings for vhost to use.
source§

fn set_vring_num(&self, queue_index: usize, num: u16) -> Result<()>

Set the number of descriptors in the vring. Read more
source§

fn set_vring_addr( &self, mem: &GuestMemory, queue_max_size: u16, queue_size: u16, queue_index: usize, flags: u32, desc_addr: GuestAddress, used_addr: GuestAddress, avail_addr: GuestAddress, log_addr: Option<GuestAddress> ) -> Result<()>

Set the addresses for a given vring. Read more
source§

fn set_vring_base(&self, queue_index: usize, num: u16) -> Result<()>

Set the first index to look for available descriptors. Read more
source§

fn get_vring_base(&self, queue_index: usize) -> Result<u16>

Gets the index of the next available descriptor in the queue. Read more
source§

fn set_vring_call(&self, queue_index: usize, event: &Event) -> Result<()>

Set the event to trigger when buffers have been used by the host. Read more
source§

fn set_vring_err(&self, queue_index: usize, event: &Event) -> Result<()>

Set the event to trigger to signal an error. Read more
source§

fn set_vring_kick(&self, queue_index: usize, event: &Event) -> Result<()>

Set the event that will be signaled by the guest when buffers are available for the host to process. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Net<T>
where T: RefUnwindSafe,

§

impl<T> Send for Net<T>
where T: Send,

§

impl<T> Sync for Net<T>
where T: Sync,

§

impl<T> Unpin for Net<T>
where T: Unpin,

§

impl<T> UnwindSafe for Net<T>
where T: UnwindSafe,

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
§

impl<T> AsRawDescriptors for T
where T: AsRawDescriptor,

§

fn as_raw_descriptors(&self) -> Vec<i32>

Returns the underlying raw descriptors. 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>,

§

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>,

§

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.