mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: vhost_user: net: Handle reconnection
This commit implements the reconnection feature for vhost-user-net in case the connection with the backend is shutdown. The guest has no knowledge about what happens when a disconnection occurs, which simplifies the code to handle the reconnection. The reconnection happens with the backend, and the VMM goes through the vhost-user setup once again. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -24,6 +24,7 @@ pub struct EpollHelper {
|
||||
pub enum EpollHelperError {
|
||||
CreateFd(std::io::Error),
|
||||
Ctl(std::io::Error),
|
||||
IoError(std::io::Error),
|
||||
Wait(std::io::Error),
|
||||
}
|
||||
|
||||
@@ -57,11 +58,35 @@ impl EpollHelper {
|
||||
}
|
||||
|
||||
pub fn add_event(&mut self, fd: RawFd, id: u16) -> std::result::Result<(), EpollHelperError> {
|
||||
self.add_event_custom(fd, id, epoll::Events::EPOLLIN)
|
||||
}
|
||||
|
||||
pub fn add_event_custom(
|
||||
&mut self,
|
||||
fd: RawFd,
|
||||
id: u16,
|
||||
evts: epoll::Events,
|
||||
) -> std::result::Result<(), EpollHelperError> {
|
||||
epoll::ctl(
|
||||
self.epoll_file.as_raw_fd(),
|
||||
epoll::ControlOptions::EPOLL_CTL_ADD,
|
||||
fd,
|
||||
epoll::Event::new(epoll::Events::EPOLLIN, id.into()),
|
||||
epoll::Event::new(evts, id.into()),
|
||||
)
|
||||
.map_err(EpollHelperError::Ctl)
|
||||
}
|
||||
|
||||
pub fn del_event_custom(
|
||||
&mut self,
|
||||
fd: RawFd,
|
||||
id: u16,
|
||||
evts: epoll::Events,
|
||||
) -> std::result::Result<(), EpollHelperError> {
|
||||
epoll::ctl(
|
||||
self.epoll_file.as_raw_fd(),
|
||||
epoll::ControlOptions::EPOLL_CTL_DEL,
|
||||
fd,
|
||||
epoll::Event::new(evts, id.into()),
|
||||
)
|
||||
.map_err(EpollHelperError::Ctl)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user