mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-20 06:51:15 +00:00
virtio-devices: Print out worker thread errors
As we never join the spawned virtio-devices worker threads, the error returned from each worker thread is lost. For now, we simply print out the error from each worker thread. Fixes: #1551 Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
df30b23f0c
commit
de3b17d948
@ -315,7 +315,7 @@ pub struct Balloon {
|
|||||||
config: Arc<Mutex<VirtioBalloonConfig>>,
|
config: Arc<Mutex<VirtioBalloonConfig>>,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
paused_sync: Arc<Barrier>,
|
paused_sync: Arc<Barrier>,
|
||||||
}
|
}
|
||||||
@ -453,7 +453,11 @@ impl VirtioDevice for Balloon {
|
|||||||
let mut epoll_threads = Vec::new();
|
let mut epoll_threads = Vec::new();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("virtio_balloon".to_string())
|
.name("virtio_balloon".to_string())
|
||||||
.spawn(move || handler.run(paused, paused_sync))
|
.spawn(move || {
|
||||||
|
if let Err(e) = handler.run(paused, paused_sync) {
|
||||||
|
error!("Error running worker: {:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|thread| epoll_threads.push(thread))
|
.map(|thread| epoll_threads.push(thread))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed to clone virtio-balloon epoll thread: {}", e);
|
error!("failed to clone virtio-balloon epoll thread: {}", e);
|
||||||
|
@ -310,7 +310,7 @@ pub struct BlockIoUring {
|
|||||||
config: VirtioBlockConfig,
|
config: VirtioBlockConfig,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
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>,
|
pause_evt: Option<EventFd>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
paused_sync: Arc<Barrier>,
|
paused_sync: Arc<Barrier>,
|
||||||
@ -601,7 +601,11 @@ impl VirtioDevice for BlockIoUring {
|
|||||||
|
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("virtio_blk".to_string())
|
.name("virtio_blk".to_string())
|
||||||
.spawn(move || handler.run(paused, paused_sync))
|
.spawn(move || {
|
||||||
|
if let Err(e) = handler.run(paused, paused_sync) {
|
||||||
|
error!("Error running worker: {:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|thread| epoll_threads.push(thread))
|
.map(|thread| epoll_threads.push(thread))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed to clone the virtio-blk epoll thread: {}", e);
|
error!("failed to clone the virtio-blk epoll thread: {}", e);
|
||||||
|
@ -689,7 +689,7 @@ pub struct Mem {
|
|||||||
config: Arc<Mutex<VirtioMemConfig>>,
|
config: Arc<Mutex<VirtioMemConfig>>,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
paused_sync: Arc<Barrier>,
|
paused_sync: Arc<Barrier>,
|
||||||
}
|
}
|
||||||
@ -854,7 +854,11 @@ impl VirtioDevice for Mem {
|
|||||||
let mut epoll_threads = Vec::new();
|
let mut epoll_threads = Vec::new();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("virtio_mem".to_string())
|
.name("virtio_mem".to_string())
|
||||||
.spawn(move || handler.run(paused, paused_sync))
|
.spawn(move || {
|
||||||
|
if let Err(e) = handler.run(paused, paused_sync) {
|
||||||
|
error!("Error running worker: {:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|thread| epoll_threads.push(thread))
|
.map(|thread| epoll_threads.push(thread))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed to clone virtio-mem epoll thread: {}", e);
|
error!("failed to clone virtio-mem epoll thread: {}", e);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
// Copyright 2019 Intel Corporation. All Rights Reserved.
|
// Copyright 2019 Intel Corporation. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{ActivateError, ActivateResult, Queue, VirtioDevice, VirtioDeviceType};
|
||||||
ActivateError, ActivateResult, EpollHelperError, Queue, VirtioDevice, VirtioDeviceType,
|
|
||||||
};
|
|
||||||
use super::handler::*;
|
use super::handler::*;
|
||||||
use super::vu_common_ctrl::*;
|
use super::vu_common_ctrl::*;
|
||||||
use super::{Error, Result};
|
use super::{Error, Result};
|
||||||
@ -42,7 +40,7 @@ pub struct Blk {
|
|||||||
queue_sizes: Vec<u16>,
|
queue_sizes: Vec<u16>,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
paused_sync: Arc<Barrier>,
|
paused_sync: Arc<Barrier>,
|
||||||
}
|
}
|
||||||
@ -278,7 +276,11 @@ impl VirtioDevice for Blk {
|
|||||||
let paused_sync = self.paused_sync.clone();
|
let paused_sync = self.paused_sync.clone();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("vhost_user_blk".to_string())
|
.name("vhost_user_blk".to_string())
|
||||||
.spawn(move || handler.run(paused, paused_sync))
|
.spawn(move || {
|
||||||
|
if let Err(e) = handler.run(paused, paused_sync) {
|
||||||
|
error!("Error running worker: {:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|thread| epoll_threads.push(thread))
|
.map(|thread| epoll_threads.push(thread))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed to clone virtio epoll thread: {}", e);
|
error!("failed to clone virtio epoll thread: {}", e);
|
||||||
|
@ -5,8 +5,8 @@ use super::vu_common_ctrl::{reset_vhost_user, setup_vhost_user, update_mem_table
|
|||||||
use super::{Error, Result};
|
use super::{Error, Result};
|
||||||
use crate::vhost_user::handler::{VhostUserEpollConfig, VhostUserEpollHandler};
|
use crate::vhost_user::handler::{VhostUserEpollConfig, VhostUserEpollHandler};
|
||||||
use crate::{
|
use crate::{
|
||||||
ActivateError, ActivateResult, EpollHelperError, Queue, UserspaceMapping, VirtioDevice,
|
ActivateError, ActivateResult, Queue, UserspaceMapping, VirtioDevice, VirtioDeviceType,
|
||||||
VirtioDeviceType, VirtioInterrupt, VirtioSharedMemoryList, VIRTIO_F_VERSION_1,
|
VirtioInterrupt, VirtioSharedMemoryList, VIRTIO_F_VERSION_1,
|
||||||
};
|
};
|
||||||
use libc::{self, c_void, off64_t, pread64, pwrite64, EFD_NONBLOCK};
|
use libc::{self, c_void, off64_t, pread64, pwrite64, EFD_NONBLOCK};
|
||||||
use std::io;
|
use std::io;
|
||||||
@ -278,7 +278,7 @@ pub struct Fs {
|
|||||||
slave_req_support: bool,
|
slave_req_support: bool,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
paused_sync: Arc<Barrier>,
|
paused_sync: Arc<Barrier>,
|
||||||
}
|
}
|
||||||
@ -506,7 +506,11 @@ impl VirtioDevice for Fs {
|
|||||||
let mut epoll_threads = Vec::new();
|
let mut epoll_threads = Vec::new();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("virtio_fs".to_string())
|
.name("virtio_fs".to_string())
|
||||||
.spawn(move || handler.run(paused, paused_sync))
|
.spawn(move || {
|
||||||
|
if let Err(e) = handler.run(paused, paused_sync) {
|
||||||
|
error!("Error running worker: {:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|thread| epoll_threads.push(thread))
|
.map(|thread| epoll_threads.push(thread))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed to clone queue EventFd: {}", e);
|
error!("failed to clone queue EventFd: {}", e);
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
use super::super::net_util::{
|
use super::super::net_util::{
|
||||||
build_net_config_space, CtrlVirtio, NetCtrlEpollHandler, VirtioNetConfig,
|
build_net_config_space, CtrlVirtio, NetCtrlEpollHandler, VirtioNetConfig,
|
||||||
};
|
};
|
||||||
use super::super::{
|
use super::super::{ActivateError, ActivateResult, Queue, VirtioDevice, VirtioDeviceType};
|
||||||
ActivateError, ActivateResult, EpollHelperError, Queue, VirtioDevice, VirtioDeviceType,
|
|
||||||
};
|
|
||||||
use super::handler::*;
|
use super::handler::*;
|
||||||
use super::vu_common_ctrl::*;
|
use super::vu_common_ctrl::*;
|
||||||
use super::{Error, Result};
|
use super::{Error, Result};
|
||||||
@ -45,8 +43,8 @@ pub struct Net {
|
|||||||
queue_sizes: Vec<u16>,
|
queue_sizes: Vec<u16>,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
|
||||||
ctrl_queue_epoll_thread: Option<thread::JoinHandle<result::Result<(), EpollHelperError>>>,
|
ctrl_queue_epoll_thread: Option<thread::JoinHandle<()>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
paused_sync: Arc<Barrier>,
|
paused_sync: Arc<Barrier>,
|
||||||
}
|
}
|
||||||
@ -268,7 +266,11 @@ impl VirtioDevice for Net {
|
|||||||
let paused_sync = self.paused_sync.clone();
|
let paused_sync = self.paused_sync.clone();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("virtio_net".to_string())
|
.name("virtio_net".to_string())
|
||||||
.spawn(move || ctrl_handler.run_ctrl(paused, paused_sync))
|
.spawn(move || {
|
||||||
|
if let Err(e) = ctrl_handler.run_ctrl(paused, paused_sync) {
|
||||||
|
error!("Error running worker: {:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|thread| self.ctrl_queue_epoll_thread = Some(thread))
|
.map(|thread| self.ctrl_queue_epoll_thread = Some(thread))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed to clone queue EventFd: {}", e);
|
error!("failed to clone queue EventFd: {}", e);
|
||||||
@ -304,7 +306,11 @@ impl VirtioDevice for Net {
|
|||||||
let paused_sync = self.paused_sync.clone();
|
let paused_sync = self.paused_sync.clone();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("vhost_user_net".to_string())
|
.name("vhost_user_net".to_string())
|
||||||
.spawn(move || handler.run(paused, paused_sync))
|
.spawn(move || {
|
||||||
|
if let Err(e) = handler.run(paused, paused_sync) {
|
||||||
|
error!("Error running worker: {:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|thread| epoll_threads.push(thread))
|
.map(|thread| epoll_threads.push(thread))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed to clone queue EventFd: {}", e);
|
error!("failed to clone queue EventFd: {}", e);
|
||||||
|
@ -305,7 +305,7 @@ pub struct Vsock<B: VsockBackend> {
|
|||||||
acked_features: u64,
|
acked_features: u64,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), EpollHelperError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
paused_sync: Arc<Barrier>,
|
paused_sync: Arc<Barrier>,
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
@ -486,7 +486,11 @@ where
|
|||||||
let mut epoll_threads = Vec::new();
|
let mut epoll_threads = Vec::new();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("virtio_vsock".to_string())
|
.name("virtio_vsock".to_string())
|
||||||
.spawn(move || handler.run(paused, paused_sync))
|
.spawn(move || {
|
||||||
|
if let Err(e) = handler.run(paused, paused_sync) {
|
||||||
|
error!("Error running worker: {:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|thread| epoll_threads.push(thread))
|
.map(|thread| epoll_threads.push(thread))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed to clone the vsock epoll thread: {}", e);
|
error!("failed to clone the vsock epoll thread: {}", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user