Trait vhost::Vhost

source ·
pub trait Vhost: AsRawDescriptor + Sized {
    // Provided methods
    fn set_owner(&self) -> Result<()> { ... }
    fn reset_owner(&self) -> Result<()> { ... }
    fn get_features(&self) -> Result<u64> { ... }
    fn set_features(&self, features: u64) -> Result<()> { ... }
    fn set_mem_table(&self, mem: &GuestMemory) -> Result<()> { ... }
    fn set_vring_num(&self, queue_index: usize, num: u16) -> Result<()> { ... }
    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<()> { ... }
    fn set_vring_base(&self, queue_index: usize, num: u16) -> Result<()> { ... }
    fn get_vring_base(&self, queue_index: usize) -> Result<u16> { ... }
    fn set_vring_call(&self, queue_index: usize, event: &Event) -> Result<()> { ... }
    fn set_vring_err(&self, queue_index: usize, event: &Event) -> Result<()> { ... }
    fn set_vring_kick(&self, queue_index: usize, event: &Event) -> Result<()> { ... }
}
Expand description

An interface for setting up vhost-based virtio devices. Vhost-based devices are different from regular virtio devices because the host kernel takes care of handling all the data transfer. The device itself only needs to deal with setting up the kernel driver and managing the control channel.

Provided Methods§

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.

§Arguments
  • features - Bitmask of features to set.
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.

§Arguments
  • queue_index - Index of the queue to set descriptor count for.
  • num - Number of descriptors in the queue.
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.

§Arguments
  • queue_max_size - Maximum queue size supported by the device.
  • queue_size - Actual queue size negotiated by the driver.
  • queue_index - Index of the queue to set addresses for.
  • flags - Bitmask of vring flags.
  • desc_addr - Descriptor table address.
  • used_addr - Used ring buffer address.
  • avail_addr - Available ring buffer address.
  • log_addr - Optional address for logging.
source

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

Set the first index to look for available descriptors.

§Arguments
  • queue_index - Index of the queue to modify.
  • num - Index where available descriptors start.
source

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

Gets the index of the next available descriptor in the queue.

§Arguments
  • queue_index - Index of the queue to query.
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.

§Arguments
  • queue_index - Index of the queue to modify.
  • event - Event to trigger.
source

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

Set the event to trigger to signal an error.

§Arguments
  • queue_index - Index of the queue to modify.
  • event - Event to trigger.
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.

§Arguments
  • queue_index - Index of the queue to modify.
  • event - Event that will be signaled from guest.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Vhost for Vsock

source§

impl<T> Vhost for FakeNet<T>

source§

impl<T> Vhost for Net<T>