virtio-devices: Print out worker error messages

Currently any messages generated during the worker thread are not
shown anywhere as the thread is never join()ed on. Instead output the
error immediately.

For now only cover the subset where the work to port to EpollHandler
clashed with the seccomp filtering for virtio devices.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-08-05 09:06:05 +01:00 committed by Sebastien Boeuf
parent ec9de259ba
commit 0e335a709d
4 changed files with 18 additions and 16 deletions

View File

@ -264,7 +264,7 @@ pub struct Block<T: DiskFile> {
config: VirtioBlockConfig,
queue_evts: Option<Vec<EventFd>>,
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
pause_evt: Option<EventFd>,
paused: Arc<AtomicBool>,
queue_size: Vec<u16>,
@ -542,10 +542,11 @@ impl<T: 'static + DiskFile + Send> VirtioDevice for Block<T> {
thread::Builder::new()
.name("virtio_blk".to_string())
.spawn(move || {
SeccompFilter::apply(virtio_blk_seccomp_filter)
.map_err(EpollHelperError::ApplySeccompFilter)?;
handler.run(paused)
if let Err(e) = SeccompFilter::apply(virtio_blk_seccomp_filter) {
error!("Error applying seccomp filter: {:?}", e);
} else if let Err(e) = handler.run(paused) {
error!("Error running worker: {:?}", e);
}
})
.map(|thread| epoll_threads.push(thread))
.map_err(|e| {

View File

@ -25,7 +25,6 @@ pub enum EpollHelperError {
CreateFd(std::io::Error),
Ctl(std::io::Error),
Wait(std::io::Error),
ApplySeccompFilter(seccomp::Error),
}
pub const EPOLL_HELPER_EVENT_PAUSE: u16 = 0;

View File

@ -285,7 +285,7 @@ pub struct Pmem {
config: VirtioPmemConfig,
queue_evts: Option<Vec<EventFd>>,
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
paused: Arc<AtomicBool>,
mapping: UserspaceMapping,
seccomp_action: SeccompAction,
@ -468,10 +468,11 @@ impl VirtioDevice for Pmem {
thread::Builder::new()
.name("virtio_pmem".to_string())
.spawn(move || {
SeccompFilter::apply(virtio_pmem_seccomp_filter)
.map_err(DeviceError::ApplySeccompFilter)?;
handler.run(paused)
if let Err(e) = SeccompFilter::apply(virtio_pmem_seccomp_filter) {
error!("Error applying seccomp filter: {:?}", e);
} else if let Err(e) = handler.run(paused) {
error!("Error running worker: {:?}", e);
}
})
.map(|thread| epoll_threads.push(thread))
.map_err(|e| {

View File

@ -130,7 +130,7 @@ pub struct Rng {
acked_features: u64,
queue_evts: Option<Vec<EventFd>>,
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
paused: Arc<AtomicBool>,
seccomp_action: SeccompAction,
}
@ -295,10 +295,11 @@ impl VirtioDevice for Rng {
thread::Builder::new()
.name("virtio_rng".to_string())
.spawn(move || {
SeccompFilter::apply(virtio_rng_seccomp_filter)
.map_err(DeviceError::ApplySeccompFilter)?;
handler.run(paused)
if let Err(e) = SeccompFilter::apply(virtio_rng_seccomp_filter) {
error!("Error applying seccomp filter: {:?}", e);
} else if let Err(e) = handler.run(paused) {
error!("Error running worker: {:?}", e);
}
})
.map(|thread| epoll_threads.push(thread))
.map_err(|e| {