Struct vmm_vhost::FrontendServer
source · pub struct FrontendServer<S: Frontend> {
pub(crate) sub_sock: Connection<BackendReq>,
reply_ack_negotiated: bool,
frontend: S,
}
Expand description
Handles requests from a vhost-user backend connection by dispatching them to [Frontend] methods.
Fields§
§sub_sock: Connection<BackendReq>
§reply_ack_negotiated: bool
§frontend: S
Implementations§
source§impl<S: Frontend> FrontendServer<S>
impl<S: Frontend> FrontendServer<S>
sourcepub fn with_stream(backend: S) -> Result<(Self, SafeDescriptor)>
pub fn with_stream(backend: S) -> Result<(Self, SafeDescriptor)>
Create a FrontendServer
that uses a Unix stream internally.
The returned SafeDescriptor
is the client side of the stream and should be sent to the
backend using BackendClient::set_slave_request_fd().
source§impl<S: Frontend> FrontendServer<S>
impl<S: Frontend> FrontendServer<S>
sourcepub(crate) fn new(
frontend: S,
connection: Connection<BackendReq>
) -> Result<Self>
pub(crate) fn new( frontend: S, connection: Connection<BackendReq> ) -> Result<Self>
Create a server to handle requests from connection
.
sourcepub fn set_reply_ack_flag(&mut self, enable: bool)
pub fn set_reply_ack_flag(&mut self, enable: bool)
Set the negotiation state of the VHOST_USER_PROTOCOL_F_REPLY_ACK
protocol feature.
When the VHOST_USER_PROTOCOL_F_REPLY_ACK
protocol feature has been negotiated,
the “REPLY_ACK” flag will be set in the message header for every request message.
sourcepub fn frontend_mut(&mut self) -> &mut S
pub fn frontend_mut(&mut self) -> &mut S
Get the underlying frontend
sourcepub fn handle_request(&mut self) -> Result<u64>
pub fn handle_request(&mut self) -> Result<u64>
Process the next received request.
The caller needs to:
- serialize calls to this function
- decide what to do when errer happens
- optional recover from failure
fn check_msg_size( &self, hdr: &VhostUserMsgHeader<BackendReq>, size: usize, expected: usize ) -> Result<()>
fn check_attached_files( &self, hdr: &VhostUserMsgHeader<BackendReq>, files: &[File] ) -> Result<()>
fn extract_msg_body<T: Sized + VhostUserMsgValidator>( &self, hdr: &VhostUserMsgHeader<BackendReq>, size: usize, buf: &[u8] ) -> Result<T>
fn new_reply_header<T: Sized>( &self, req: &VhostUserMsgHeader<BackendReq> ) -> Result<VhostUserMsgHeader<BackendReq>>
fn send_reply( &mut self, req: &VhostUserMsgHeader<BackendReq>, res: &Result<u64> ) -> Result<()>
Trait Implementations§
source§impl<S: Frontend> AsRawDescriptor for FrontendServer<S>
impl<S: Frontend> AsRawDescriptor for FrontendServer<S>
source§fn as_raw_descriptor(&self) -> RawDescriptor
fn as_raw_descriptor(&self) -> RawDescriptor
Returns the underlying raw descriptor. Read more
source§impl<S: Frontend> ReadNotifier for FrontendServer<S>
impl<S: Frontend> ReadNotifier for FrontendServer<S>
source§fn get_read_notifier(&self) -> &dyn AsRawDescriptor
fn get_read_notifier(&self) -> &dyn AsRawDescriptor
Gets a descriptor that can be used in EventContext to wait for events to be available (e.g.
to avoid receive_events blocking).
Auto Trait Implementations§
impl<S> !RefUnwindSafe for FrontendServer<S>
impl<S> Send for FrontendServer<S>where
S: Send,
impl<S> !Sync for FrontendServer<S>
impl<S> Unpin for FrontendServer<S>where
S: Unpin,
impl<S> UnwindSafe for FrontendServer<S>where
S: UnwindSafe,
Blanket Implementations§
§impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
§fn as_raw_descriptors(&self) -> Vec<i32>
fn as_raw_descriptors(&self) -> Vec<i32>
Returns the underlying raw descriptors. Read more
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more