bin: vhost_user_fs: Port to new exit event strategy

Rather than handling the KILL_EVENT in the event handler itself use the
newly added support in VhostUserBackend for providing a kill event
framework.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-02-11 11:27:03 +00:00 committed by Sebastien Boeuf
parent 759a0be6cd
commit da7f31d4bc

View File

@ -13,7 +13,6 @@ use clap::{App, Arg};
use epoll;
use libc::EFD_NONBLOCK;
use log::*;
use std::os::unix::io::AsRawFd;
use std::sync::{Arc, RwLock};
use std::{convert, error, fmt, io, process};
@ -165,16 +164,15 @@ impl<F: FileSystem + Send + Sync + 'static> VhostUserBackend for VhostUserFsBack
let mut vring = vrings[1].write().unwrap();
self.process_queue(&mut vring)?;
}
KILL_EVENT => {
debug!("KILL_EVENT");
self.kill_evt.read().unwrap();
return Ok(true);
}
_ => return Err(Error::HandleEventUnknownEvent.into()),
}
Ok(false)
}
fn exit_event(&self) -> Option<(EventFd, Option<u16>)> {
Some((self.kill_evt.try_clone().unwrap(), Some(KILL_EVENT)))
}
}
fn main() {
@ -223,17 +221,6 @@ fn main() {
)
.unwrap();
let vring_worker = daemon.get_vring_worker();
if let Err(e) = vring_worker.register_listener(
fs_backend.read().unwrap().kill_evt.as_raw_fd(),
epoll::Events::EPOLLIN,
u64::from(KILL_EVENT),
) {
error!("Failed to register listener for kill event: {:?}", e);
process::exit(1);
}
if let Err(e) = daemon.start() {
error!("Failed to start daemon: {:?}", e);
process::exit(1);