pub trait VhostUserDevice {
Show 17 methods // Required methods fn max_queue_num(&self) -> usize; fn features(&self) -> u64; fn ack_features(&mut self, value: u64) -> Result<()>; fn acked_features(&self) -> u64; fn protocol_features(&self) -> VhostUserProtocolFeatures; fn ack_protocol_features(&mut self, _value: u64) -> Result<()>; fn acked_protocol_features(&self) -> u64; fn read_config(&self, offset: u64, dst: &mut [u8]); fn start_queue( &mut self, idx: usize, queue: Queue, mem: GuestMemory, doorbell: Interrupt ) -> Result<()>; fn stop_queue(&mut self, idx: usize) -> Result<Queue>; fn reset(&mut self); // Provided methods fn write_config(&self, _offset: u64, _data: &[u8]) { ... } fn get_shared_memory_region(&self) -> Option<SharedMemoryRegion> { ... } fn set_backend_req_connection( &mut self, _conn: Arc<VhostBackendReqConnection> ) { ... } fn stop_non_queue_workers(&mut self) -> Result<()> { ... } fn snapshot(&self) -> Result<Vec<u8>> { ... } fn restore(&mut self, _data: Vec<u8>) -> Result<()> { ... }
}
Expand description

Trait for vhost-user devices. Analogous to the VirtioDevice trait.

In contrast with [vmm_vhost::Backend], which closely matches the vhost-user spec, this trait is designed to follow crosvm conventions for implementing devices.

Required Methods§

source

fn max_queue_num(&self) -> usize

The maximum number of queues that this backend can manage.

source

fn features(&self) -> u64

The set of feature bits that this backend supports.

source

fn ack_features(&mut self, value: u64) -> Result<()>

Acknowledges that this set of features should be enabled.

source

fn acked_features(&self) -> u64

Returns the set of enabled features.

source

fn protocol_features(&self) -> VhostUserProtocolFeatures

The set of protocol feature bits that this backend supports.

source

fn ack_protocol_features(&mut self, _value: u64) -> Result<()>

Acknowledges that this set of protocol features should be enabled.

source

fn acked_protocol_features(&self) -> u64

Returns the set of enabled protocol features.

source

fn read_config(&self, offset: u64, dst: &mut [u8])

Reads this device configuration space at offset.

source

fn start_queue( &mut self, idx: usize, queue: Queue, mem: GuestMemory, doorbell: Interrupt ) -> Result<()>

Indicates that the backend should start processing requests for virtio queue number idx. This method must not block the current thread so device backends should either spawn an async task or another thread to handle messages from the Queue.

source

fn stop_queue(&mut self, idx: usize) -> Result<Queue>

Indicates that the backend should stop processing requests for virtio queue number idx. This method should return the queue passed to start_queue for the corresponding idx. This method will only be called for queues that were previously started by start_queue.

source

fn reset(&mut self)

Resets the vhost-user backend.

Provided Methods§

source

fn write_config(&self, _offset: u64, _data: &[u8])

writes data to this device’s configuration space at offset.

source

fn get_shared_memory_region(&self) -> Option<SharedMemoryRegion>

Returns the device’s shared memory region if present.

source

fn set_backend_req_connection(&mut self, _conn: Arc<VhostBackendReqConnection>)

Accepts VhostBackendReqConnection to conduct Vhost backend to frontend message handling.

The backend is given an Arc instead of full ownership so that the framework can also use the connection.

This method will be called when VhostUserProtocolFeatures::BACKEND_REQ is negotiated.

source

fn stop_non_queue_workers(&mut self) -> Result<()>

Used to stop non queue workers that VhostUserDevice::stop_queue can’t stop. May or may not also stop all queue workers.

source

fn snapshot(&self) -> Result<Vec<u8>>

Snapshot device and return serialized bytes.

source

fn restore(&mut self, _data: Vec<u8>) -> Result<()>

Implementors§