Trait devices::virtio::vhost::user::device::connection::VhostUserConnectionTrait
source · pub trait VhostUserConnectionTrait {
// Required method
fn run_req_handler<'e>(
self,
handler: Box<dyn Backend>,
ex: &'e Executor
) -> Pin<Box<dyn Future<Output = Result<()>> + 'e>>;
// Provided methods
fn take_parent_process_resources(&mut self) -> Option<Box<dyn Any>> { ... }
fn run_backend<'e>(
self,
backend: impl VhostUserDevice + 'static,
ex: &'e Executor
) -> Pin<Box<dyn Future<Output = Result<()>> + 'e>>
where Self: Sized { ... }
fn run_device(
self,
ex: Executor,
device: Box<dyn VhostUserDeviceBuilder>
) -> Result<()>
where Self: Sized { ... }
}
Expand description
Trait that the platform-specific type VhostUserConnection
needs to implement. It contains all
the methods that are ok to call from non-platform specific code.
Required Methods§
Provided Methods§
sourcefn take_parent_process_resources(&mut self) -> Option<Box<dyn Any>>
fn take_parent_process_resources(&mut self) -> Option<Box<dyn Any>>
Take and return resources owned by the parent process in case of a incoming fork.
This method needs to be called only if you are going to use the connection in a jailed child process. In this case, the connection will belong to the child and the parent will drop it, but the child may lack the rights to drop some resources created at construction time. One such example is the socket file of a regular vhost-user device, that cannot be dropped by the child unless it gets extra permissions.
This method returns an opaque object that, upon being dropped, will free these resources. That way, the child process does not need extra rights to clear them, and the parent can drop the connection after forking and just need to keep that object alive until the child exits to do housekeeping properly.
The default implementation returns nothing as that’s what most connection would need anyway.
sourcefn run_backend<'e>(
self,
backend: impl VhostUserDevice + 'static,
ex: &'e Executor
) -> Pin<Box<dyn Future<Output = Result<()>> + 'e>>where
Self: Sized,
fn run_backend<'e>(
self,
backend: impl VhostUserDevice + 'static,
ex: &'e Executor
) -> Pin<Box<dyn Future<Output = Result<()>> + 'e>>where
Self: Sized,
Returns a Future
that will process requests from backend
when polled. The future exits
when the front-end side disconnects or an error occurs.
This is a legacy way to run devices - prefer run_device
.
sourcefn run_device(
self,
ex: Executor,
device: Box<dyn VhostUserDeviceBuilder>
) -> Result<()>where
Self: Sized,
fn run_device(
self,
ex: Executor,
device: Box<dyn VhostUserDeviceBuilder>
) -> Result<()>where
Self: Sized,
Start processing requests for a VhostUserDevice
on connection
. Returns when the
front-end side disconnects or an error occurs.