pub struct VhostUserDaemon<S, V, B: Bitmap + 'static = ()> { /* private fields */ }
Expand description

Implement a simple framework to run a vhost-user service daemon.

This structure is the public API the backend is allowed to interact with in order to run a fully functional vhost-user daemon.

Implementations§

source§

impl<S, V, B> VhostUserDaemon<S, V, B>where S: VhostUserBackend<V, B> + Clone + 'static, V: VringT<GuestMemoryAtomic<GuestMemoryMmap<B>>> + Clone + Send + Sync + 'static, B: NewBitmap + Clone + Send + Sync,

source

pub fn new( name: String, backend: S, atomic_mem: GuestMemoryAtomic<GuestMemoryMmap<B>> ) -> Result<Self>

Create the daemon instance, providing the backend implementation of VhostUserBackend.

Under the hood, this will start a dedicated thread responsible for listening onto registered event. Those events can be vring events or custom events from the backend, but they get to be registered later during the sequence.

source

pub fn start_client(&mut self, socket_path: &str) -> Result<()>

Connect to the vhost-user socket and run a dedicated thread handling all requests coming through this socket. This runs in an infinite loop that should be terminating once the other end of the socket (the VMM) hangs up.

source

pub fn start(&mut self, listener: Listener) -> Result<()>

Listen to the vhost-user socket and run a dedicated thread handling all requests coming through this socket.

This runs in an infinite loop that should be terminating once the other end of the socket (the VMM) disconnects.

source

pub fn wait(&mut self) -> Result<()>

Wait for the thread handling the vhost-user socket connection to terminate.

source

pub fn get_epoll_handlers(&self) -> Vec<Arc<VringEpollHandler<S, V, B>>>

Retrieve the vring epoll handler.

This is necessary to perform further actions like registering and unregistering some extra event file descriptors.

Auto Trait Implementations§

§

impl<S, V, B = ()> !RefUnwindSafe for VhostUserDaemon<S, V, B>

§

impl<S, V, B> Send for VhostUserDaemon<S, V, B>where B: Send + Sync, S: Send + Sync, V: Send + Sync,

§

impl<S, V, B> Sync for VhostUserDaemon<S, V, B>where B: Send + Sync, S: Send + Sync, V: Send + Sync,

§

impl<S, V, B> Unpin for VhostUserDaemon<S, V, B>

§

impl<S, V, B = ()> !UnwindSafe for VhostUserDaemon<S, V, B>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.