pub trait VhostUserListenerTrait {
    // Required methods
    fn new(
        path: &str,
        keep_rds: Option<&mut Vec<RawDescriptor>>
    ) -> Result<VhostUserListener>;
    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 VhostUserListener needs to implement. It contains all the methods that are ok to call from non-platform specific code.

Required Methods§

source

fn new( path: &str, keep_rds: Option<&mut Vec<RawDescriptor>> ) -> Result<VhostUserListener>

Creates a VhostUserListener from path, which is a platform-specific string describing how to establish the vhost-user channel. For instance, it can be a path to a socket.

keep_rds is a vector of RawDescriptors to which the descriptors needed for this listener to operate properly will be added if it is Some().

source

fn run_req_handler<'e>( self, handler: Box<dyn Backend>, ex: &'e Executor ) -> Pin<Box<dyn Future<Output = Result<()>> + 'e>>

Returns a Future that processes requests for handler. The future exits when the front-end side disconnects or an error occurs.

Provided Methods§

source

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 listener in a jailed child process. In this case, the listener 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 listener 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 listeners would need anyway.

source

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.

source

fn run_device( self, ex: Executor, device: Box<dyn VhostUserDeviceBuilder> ) -> Result<()>where Self: Sized,

Start processing requests for a VhostUserDevice on listener. Returns when the front-end side disconnects or an error occurs.

Implementors§