mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-25 01:11:16 +00:00
vhost_user_backend: Make the backend a server
The code needs to initialize a listener to accept connection from the VMM being the client in this case. Signed-off-by: Cathy Zhang <cathy.zhang@intel.com> Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
c1b26b1fab
commit
1aab372a06
@ -18,7 +18,7 @@ use vhost_rs::vhost_user::message::{
|
|||||||
VHOST_USER_CONFIG_OFFSET, VHOST_USER_CONFIG_SIZE,
|
VHOST_USER_CONFIG_OFFSET, VHOST_USER_CONFIG_SIZE,
|
||||||
};
|
};
|
||||||
use vhost_rs::vhost_user::{
|
use vhost_rs::vhost_user::{
|
||||||
Error as VhostUserError, Result as VhostUserResult, SlaveReqHandler, VhostUserSlaveReqHandler,
|
Error as VhostUserError, Result as VhostUserResult, SlaveListener, VhostUserSlaveReqHandler,
|
||||||
};
|
};
|
||||||
use vm_memory::guest_memory::FileOffset;
|
use vm_memory::guest_memory::FileOffset;
|
||||||
use vm_memory::{GuestAddress, GuestMemoryMmap};
|
use vm_memory::{GuestAddress, GuestMemoryMmap};
|
||||||
@ -30,6 +30,8 @@ use vmm_sys_util::eventfd::EventFd;
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failed to create a new vhost-user handler.
|
/// Failed to create a new vhost-user handler.
|
||||||
NewVhostUserHandler(VhostUserHandlerError),
|
NewVhostUserHandler(VhostUserHandlerError),
|
||||||
|
/// Failed creating vhost-user slave listener.
|
||||||
|
CreateSlaveListener(VhostUserError),
|
||||||
/// Failed creating vhost-user slave handler.
|
/// Failed creating vhost-user slave handler.
|
||||||
CreateSlaveReqHandler(VhostUserError),
|
CreateSlaveReqHandler(VhostUserError),
|
||||||
/// Failed starting daemon thread.
|
/// Failed starting daemon thread.
|
||||||
@ -126,9 +128,13 @@ impl<S: VhostUserBackend> VhostUserDaemon<S> {
|
|||||||
/// that should be terminating once the other end of the socket (the VMM)
|
/// that should be terminating once the other end of the socket (the VMM)
|
||||||
/// disconnects.
|
/// disconnects.
|
||||||
pub fn start(&mut self) -> Result<()> {
|
pub fn start(&mut self) -> Result<()> {
|
||||||
let mut slave_handler =
|
let mut slave_listener =
|
||||||
SlaveReqHandler::connect(self.sock_path.as_str(), self.handler.clone())
|
SlaveListener::new(self.sock_path.as_str(), false, self.handler.clone())
|
||||||
.map_err(Error::CreateSlaveReqHandler)?;
|
.map_err(Error::CreateSlaveListener)?;
|
||||||
|
let mut slave_handler = slave_listener
|
||||||
|
.accept()
|
||||||
|
.map_err(Error::CreateSlaveReqHandler)?
|
||||||
|
.unwrap();
|
||||||
let handle = thread::Builder::new()
|
let handle = thread::Builder::new()
|
||||||
.name(self.name.clone())
|
.name(self.name.clone())
|
||||||
.spawn(move || loop {
|
.spawn(move || loop {
|
||||||
|
Loading…
Reference in New Issue
Block a user