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§
sourcefn set_owner(&self) -> Result<()>
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.
sourcefn reset_owner(&self) -> Result<()>
fn reset_owner(&self) -> Result<()>
Give up ownership and reset the device to default values. Allows a subsequent call to
set_owner
to succeed.
sourcefn get_features(&self) -> Result<u64>
fn get_features(&self) -> Result<u64>
Get a bitmask of supported virtio/vhost features.
sourcefn set_features(&self, features: u64) -> Result<()>
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.
sourcefn set_mem_table(&self, mem: &GuestMemory) -> Result<()>
fn set_mem_table(&self, mem: &GuestMemory) -> Result<()>
Set the guest memory mappings for vhost to use.
sourcefn set_vring_num(&self, queue_index: usize, num: u16) -> Result<()>
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.
sourcefn 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_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.
sourcefn set_vring_base(&self, queue_index: usize, num: u16) -> Result<()>
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.
sourcefn get_vring_base(&self, queue_index: usize) -> Result<u16>
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.
sourcefn set_vring_call(&self, queue_index: usize, event: &Event) -> Result<()>
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.