mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: Make all virtio devices potentially multi-threaded
Although only the block and net virtio devices can actually be multi threaded (for now), handling them as special cases makes the code more complex. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
ac8e4b9cb6
commit
f648f2856d
@@ -775,7 +775,7 @@ pub struct Block<T: DiskFile> {
|
||||
config_space: Vec<u8>,
|
||||
queue_evt: Option<EventFd>,
|
||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||
epoll_thread: Option<thread::JoinHandle<result::Result<(), DeviceError>>>,
|
||||
epoll_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||
pause_evt: Option<EventFd>,
|
||||
paused: Arc<AtomicBool>,
|
||||
}
|
||||
@@ -975,15 +975,18 @@ impl<T: 'static + DiskFile + Send> VirtioDevice for Block<T> {
|
||||
};
|
||||
|
||||
let paused = self.paused.clone();
|
||||
let mut epoll_threads = Vec::new();
|
||||
thread::Builder::new()
|
||||
.name("virtio_blk".to_string())
|
||||
.spawn(move || handler.run(queue_evt, paused))
|
||||
.map(|thread| self.epoll_thread = Some(thread))
|
||||
.map(|thread| epoll_threads.push(thread))
|
||||
.map_err(|e| {
|
||||
error!("failed to clone the virtio-blk epoll thread: {}", e);
|
||||
ActivateError::BadActivate
|
||||
})?;
|
||||
|
||||
self.epoll_thread = Some(epoll_threads);
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
Err(ActivateError::BadActivate)
|
||||
|
||||
Reference in New Issue
Block a user