mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-23 06:05:21 +00:00
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:
parent
759a0be6cd
commit
da7f31d4bc
@ -13,7 +13,6 @@ use clap::{App, Arg};
|
|||||||
use epoll;
|
use epoll;
|
||||||
use libc::EFD_NONBLOCK;
|
use libc::EFD_NONBLOCK;
|
||||||
use log::*;
|
use log::*;
|
||||||
use std::os::unix::io::AsRawFd;
|
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
use std::{convert, error, fmt, io, process};
|
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();
|
let mut vring = vrings[1].write().unwrap();
|
||||||
self.process_queue(&mut vring)?;
|
self.process_queue(&mut vring)?;
|
||||||
}
|
}
|
||||||
KILL_EVENT => {
|
|
||||||
debug!("KILL_EVENT");
|
|
||||||
self.kill_evt.read().unwrap();
|
|
||||||
return Ok(true);
|
|
||||||
}
|
|
||||||
_ => return Err(Error::HandleEventUnknownEvent.into()),
|
_ => return Err(Error::HandleEventUnknownEvent.into()),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn exit_event(&self) -> Option<(EventFd, Option<u16>)> {
|
||||||
|
Some((self.kill_evt.try_clone().unwrap(), Some(KILL_EVENT)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -223,17 +221,6 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.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() {
|
if let Err(e) = daemon.start() {
|
||||||
error!("Failed to start daemon: {:?}", e);
|
error!("Failed to start daemon: {:?}", e);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user