From 0e335a709d7b42570ab1b0dbe2b1c0a4df09735d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 5 Aug 2020 09:06:05 +0100 Subject: [PATCH] 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 --- virtio-devices/src/block.rs | 11 ++++++----- virtio-devices/src/epoll_helper.rs | 1 - virtio-devices/src/pmem.rs | 11 ++++++----- virtio-devices/src/rng.rs | 11 ++++++----- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/virtio-devices/src/block.rs b/virtio-devices/src/block.rs index 053e02e7a..c42e4a053 100644 --- a/virtio-devices/src/block.rs +++ b/virtio-devices/src/block.rs @@ -264,7 +264,7 @@ pub struct Block { config: VirtioBlockConfig, queue_evts: Option>, interrupt_cb: Option>, - epoll_threads: Option>>>, + epoll_threads: Option>>, pause_evt: Option, paused: Arc, queue_size: Vec, @@ -542,10 +542,11 @@ impl VirtioDevice for Block { 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| { diff --git a/virtio-devices/src/epoll_helper.rs b/virtio-devices/src/epoll_helper.rs index d0bae0b6b..0cf306aa9 100644 --- a/virtio-devices/src/epoll_helper.rs +++ b/virtio-devices/src/epoll_helper.rs @@ -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; diff --git a/virtio-devices/src/pmem.rs b/virtio-devices/src/pmem.rs index 89018433f..aa630d3d6 100644 --- a/virtio-devices/src/pmem.rs +++ b/virtio-devices/src/pmem.rs @@ -285,7 +285,7 @@ pub struct Pmem { config: VirtioPmemConfig, queue_evts: Option>, interrupt_cb: Option>, - epoll_threads: Option>>>, + epoll_threads: Option>>, paused: Arc, 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| { diff --git a/virtio-devices/src/rng.rs b/virtio-devices/src/rng.rs index 97af3777f..0e0a309d0 100644 --- a/virtio-devices/src/rng.rs +++ b/virtio-devices/src/rng.rs @@ -130,7 +130,7 @@ pub struct Rng { acked_features: u64, queue_evts: Option>, interrupt_cb: Option>, - epoll_threads: Option>>>, + epoll_threads: Option>>, paused: Arc, 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| {