From b8622b5c69065161bc140e1267b3d995389b6751 Mon Sep 17 00:00:00 2001 From: Cathy Zhang Date: Tue, 3 Sep 2019 15:55:20 +0800 Subject: [PATCH] vm-virtio: Address event count error and refactor data setting New event is added in VhostUserEpollHandler for vhost-user fs, but the total event count is not update accordingly. Fix the issue and refactor the event data setting for new event expansion in the future. Signed-off-by: Cathy Zhang --- vm-virtio/src/vhost_user/handler.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vm-virtio/src/vhost_user/handler.rs b/vm-virtio/src/vhost_user/handler.rs index 572e55712..ee37ba313 100644 --- a/vm-virtio/src/vhost_user/handler.rs +++ b/vm-virtio/src/vhost_user/handler.rs @@ -79,8 +79,10 @@ impl VhostUserEpollHandler { ) .map_err(Error::EpollCtl)?; + let mut index = kill_evt_index; + let slave_evt_index = if let Some(self_req_handler) = &self.vu_epoll_cfg.slave_req_handler { - let index = kill_evt_index + 1; + index = kill_evt_index + 1; epoll::ctl( epoll_fd, epoll::ControlOptions::EPOLL_CTL_ADD, @@ -94,7 +96,7 @@ impl VhostUserEpollHandler { None }; - let mut events = vec![epoll::Event::new(epoll::Events::empty(), 0); kill_evt_index + 1]; + let mut events = vec![epoll::Event::new(epoll::Events::empty(), 0); index + 1]; 'poll: loop { let num_events = match epoll::wait(epoll_fd, -1, &mut events[..]) {