Struct vhost_user_backend::VhostUserDaemon
source · [−]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
sourceimpl<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,
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,
sourcepub fn new(
name: String,
backend: S,
atomic_mem: GuestMemoryAtomic<GuestMemoryMmap<B>>
) -> Result<Self>
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.
sourcepub fn start_client(&mut self, socket_path: &str) -> Result<()>
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.
sourcepub fn start(&mut self, listener: Listener) -> Result<()>
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.
sourcepub fn wait(&mut self) -> Result<()>
pub fn wait(&mut self) -> Result<()>
Wait for the thread handling the vhost-user socket connection to terminate.
sourcepub fn get_epoll_handlers(&self) -> Vec<Arc<VringEpollHandler<S, V, B>>>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more