Struct vmm_vhost::backend_client::BackendClient
source · pub struct BackendClient {
connection: Connection<FrontendReq>,
virtio_features: u64,
acked_virtio_features: u64,
acked_protocol_features: u64,
}
Expand description
Client for a vhost-user device. The API is a thin abstraction over the vhost-user protocol.
Fields§
§connection: Connection<FrontendReq>
§virtio_features: u64
§acked_virtio_features: u64
§acked_protocol_features: u64
Implementations§
source§impl BackendClient
impl BackendClient
sourcepub fn new(connection: Connection<FrontendReq>) -> Self
pub fn new(connection: Connection<FrontendReq>) -> Self
Create a new instance.
sourcepub fn get_features(&mut self) -> Result<u64>
pub fn get_features(&mut self) -> Result<u64>
Get a bitmask of supported virtio/vhost features.
sourcepub fn set_features(&mut self, features: u64) -> Result<()>
pub fn set_features(&mut self, features: u64) -> Result<()>
Inform the vhost subsystem which features to enable. This should be a subset of supported features from get_features().
sourcepub fn set_owner(&self) -> Result<()>
pub fn set_owner(&self) -> Result<()>
Set the current process as the owner of the vhost backend. This must be run before any other vhost commands.
sourcepub fn reset_owner(&self) -> Result<()>
pub fn reset_owner(&self) -> Result<()>
Used to be sent to request disabling all rings This is no longer used.
sourcepub fn set_mem_table(&self, regions: &[VhostUserMemoryRegionInfo]) -> Result<()>
pub fn set_mem_table(&self, regions: &[VhostUserMemoryRegionInfo]) -> Result<()>
Set the memory map regions on the backend so it can translate the vring addresses. In the ancillary data there is an array of file descriptors
sourcepub fn set_log_base(&self, base: u64, fd: Option<RawDescriptor>) -> Result<()>
pub fn set_log_base(&self, base: u64, fd: Option<RawDescriptor>) -> Result<()>
Set base address for page modification logging.
sourcepub fn set_log_fd(&self, fd: RawDescriptor) -> Result<()>
pub fn set_log_fd(&self, fd: RawDescriptor) -> Result<()>
Specify an event file descriptor to signal on log write.
sourcepub fn set_vring_num(&self, queue_index: usize, num: u16) -> Result<()>
pub fn set_vring_num(&self, queue_index: usize, num: u16) -> Result<()>
Set the number of descriptors in the vring.
sourcepub fn set_vring_addr(
&self,
queue_index: usize,
config_data: &VringConfigData
) -> Result<()>
pub fn set_vring_addr( &self, queue_index: usize, config_data: &VringConfigData ) -> Result<()>
Set the addresses for a given vring.
sourcepub fn set_vring_base(&self, queue_index: usize, base: u16) -> Result<()>
pub fn set_vring_base(&self, queue_index: usize, base: u16) -> Result<()>
Set the first index to look for available descriptors.
sourcepub fn get_vring_base(&self, queue_index: usize) -> Result<u32>
pub fn get_vring_base(&self, queue_index: usize) -> Result<u32>
Get the available vring base offset.
sourcepub fn set_vring_call(&self, queue_index: usize, event: &Event) -> Result<()>
pub fn set_vring_call(&self, queue_index: usize, event: &Event) -> Result<()>
Set the event to trigger when buffers have been used by the host.
Bits (0-7) of the payload contain the vring index. Bit 8 is the invalid FD flag. This flag is set when there is no file descriptor in the ancillary data. This signals that polling will be used instead of waiting for the call.
sourcepub fn set_vring_kick(&self, queue_index: usize, event: &Event) -> Result<()>
pub 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.
Bits (0-7) of the payload contain the vring index. Bit 8 is the invalid FD flag. This flag is set when there is no file descriptor in the ancillary data. This signals that polling should be used instead of waiting for a kick.
sourcepub fn set_vring_err(&self, queue_index: usize, event: &Event) -> Result<()>
pub fn set_vring_err(&self, queue_index: usize, event: &Event) -> Result<()>
Set the event that will be signaled by the guest when error happens.
Bits (0-7) of the payload contain the vring index. Bit 8 is the invalid FD flag. This flag is set when there is no file descriptor in the ancillary data.
sourcepub fn set_device_state_fd(
&self,
transfer_direction: VhostUserTransferDirection,
migration_phase: VhostUserMigrationPhase,
fd: &impl AsRawDescriptor
) -> Result<Option<File>>
pub fn set_device_state_fd( &self, transfer_direction: VhostUserTransferDirection, migration_phase: VhostUserMigrationPhase, fd: &impl AsRawDescriptor ) -> Result<Option<File>>
Front-end and back-end negotiate a channel over which to transfer the back-end’s internal state during migration.
Requires VHOST_USER_PROTOCOL_F_DEVICE_STATE to be negotiated.
sourcepub fn check_device_state(&self) -> Result<()>
pub fn check_device_state(&self) -> Result<()>
After transferring the back-end’s internal state during migration, check whether the back-end was able to successfully fully process the state.
sourcepub fn get_protocol_features(&self) -> Result<VhostUserProtocolFeatures>
pub fn get_protocol_features(&self) -> Result<VhostUserProtocolFeatures>
Get the protocol feature bitmask from the underlying vhost implementation.
sourcepub fn set_protocol_features(
&mut self,
features: VhostUserProtocolFeatures
) -> Result<()>
pub fn set_protocol_features( &mut self, features: VhostUserProtocolFeatures ) -> Result<()>
Enable protocol features in the underlying vhost implementation.
sourcepub fn get_queue_num(&self) -> Result<u64>
pub fn get_queue_num(&self) -> Result<u64>
Query how many queues the backend supports.
sourcepub fn set_vring_enable(&self, queue_index: usize, enable: bool) -> Result<()>
pub fn set_vring_enable(&self, queue_index: usize, enable: bool) -> Result<()>
Signal backend to enable or disable corresponding vring.
Backend must not pass data to/from the ring until ring is enabled by VHOST_USER_SET_VRING_ENABLE with parameter 1, or after it has been disabled by VHOST_USER_SET_VRING_ENABLE with parameter 0.
sourcepub fn get_config(
&self,
offset: u32,
size: u32,
flags: VhostUserConfigFlags,
buf: &[u8]
) -> Result<(VhostUserConfig, VhostUserConfigPayload)>
pub fn get_config( &self, offset: u32, size: u32, flags: VhostUserConfigFlags, buf: &[u8] ) -> Result<(VhostUserConfig, VhostUserConfigPayload)>
Fetch the contents of the virtio device configuration space.
sourcepub fn set_config(
&self,
offset: u32,
flags: VhostUserConfigFlags,
buf: &[u8]
) -> Result<()>
pub fn set_config( &self, offset: u32, flags: VhostUserConfigFlags, buf: &[u8] ) -> Result<()>
Change the virtio device configuration space. It also can be used for live migration on the destination host to set readonly configuration space fields.
sourcepub fn set_backend_req_fd(&self, fd: &dyn AsRawDescriptor) -> Result<()>
pub fn set_backend_req_fd(&self, fd: &dyn AsRawDescriptor) -> Result<()>
Setup backend communication channel.
sourcepub fn get_inflight_fd(
&self,
inflight: &VhostUserInflight
) -> Result<(VhostUserInflight, File)>
pub fn get_inflight_fd( &self, inflight: &VhostUserInflight ) -> Result<(VhostUserInflight, File)>
Retrieve shared buffer for inflight I/O tracking.
sourcepub fn set_inflight_fd(
&self,
inflight: &VhostUserInflight,
fd: RawDescriptor
) -> Result<()>
pub fn set_inflight_fd( &self, inflight: &VhostUserInflight, fd: RawDescriptor ) -> Result<()>
Set shared buffer for inflight I/O tracking.
sourcepub fn get_max_mem_slots(&self) -> Result<u64>
pub fn get_max_mem_slots(&self) -> Result<u64>
Query the maximum amount of memory slots supported by the backend.
sourcepub fn add_mem_region(&self, region: &VhostUserMemoryRegionInfo) -> Result<()>
pub fn add_mem_region(&self, region: &VhostUserMemoryRegionInfo) -> Result<()>
Add a new guest memory mapping for vhost to use.
sourcepub fn remove_mem_region(
&self,
region: &VhostUserMemoryRegionInfo
) -> Result<()>
pub fn remove_mem_region( &self, region: &VhostUserMemoryRegionInfo ) -> Result<()>
Remove a guest memory mapping from vhost.
Gets the shared memory regions used by the device.