mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
vm-virtio: Rename epoll_thread to epoll_threads
Now that we unified epoll_thread to potentially be a vector of threads, it makes sense to make it a plural field. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
f648f2856d
commit
c06a827cbb
@ -775,7 +775,7 @@ pub struct Block<T: DiskFile> {
|
|||||||
config_space: Vec<u8>,
|
config_space: Vec<u8>,
|
||||||
queue_evt: Option<EventFd>,
|
queue_evt: Option<EventFd>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
pause_evt: Option<EventFd>,
|
pause_evt: Option<EventFd>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
@ -831,7 +831,7 @@ impl<T: DiskFile> Block<T> {
|
|||||||
config_space: build_config_space(disk_size),
|
config_space: build_config_space(disk_size),
|
||||||
queue_evt: None,
|
queue_evt: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
pause_evt: None,
|
pause_evt: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
})
|
})
|
||||||
@ -985,7 +985,7 @@ impl<T: 'static + DiskFile + Send> VirtioDevice for Block<T> {
|
|||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_threads);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ pub struct Console {
|
|||||||
out: Arc<Mutex<Box<dyn io::Write + Send + Sync + 'static>>>,
|
out: Arc<Mutex<Box<dyn io::Write + Send + Sync + 'static>>>,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ impl Console {
|
|||||||
out: Arc::new(Mutex::new(out)),
|
out: Arc::new(Mutex::new(out)),
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
},
|
},
|
||||||
console_input,
|
console_input,
|
||||||
@ -554,7 +554,7 @@ impl VirtioDevice for Console {
|
|||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_threads);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -136,9 +136,9 @@ macro_rules! virtio_pausable_inner {
|
|||||||
VirtioDeviceType::from(self.device_type())
|
VirtioDeviceType::from(self.device_type())
|
||||||
);
|
);
|
||||||
self.paused.store(false, Ordering::SeqCst);
|
self.paused.store(false, Ordering::SeqCst);
|
||||||
if let Some(epoll_thread) = &self.epoll_thread {
|
if let Some(epoll_threads) = &self.epoll_threads {
|
||||||
for i in 0..epoll_thread.len() {
|
for i in 0..epoll_threads.len() {
|
||||||
epoll_thread[i].thread().unpark();
|
epoll_threads[i].thread().unpark();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,9 +168,9 @@ macro_rules! virtio_pausable_inner {
|
|||||||
);
|
);
|
||||||
self.paused.store(false, Ordering::SeqCst);
|
self.paused.store(false, Ordering::SeqCst);
|
||||||
|
|
||||||
if let Some(epoll_thread) = &self.epoll_thread {
|
if let Some(epoll_threads) = &self.epoll_threads {
|
||||||
for i in 0..epoll_thread.len() {
|
for i in 0..epoll_threads.len() {
|
||||||
epoll_thread[i].thread().unpark();
|
epoll_threads[i].thread().unpark();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ pub struct Iommu {
|
|||||||
ext_mapping: BTreeMap<u32, Arc<dyn ExternalDmaMapping>>,
|
ext_mapping: BTreeMap<u32, Arc<dyn ExternalDmaMapping>>,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,7 +795,7 @@ impl Iommu {
|
|||||||
ext_mapping: BTreeMap::new(),
|
ext_mapping: BTreeMap::new(),
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
},
|
},
|
||||||
mapping,
|
mapping,
|
||||||
@ -948,7 +948,7 @@ impl VirtioDevice for Iommu {
|
|||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_threads);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ pub struct Net {
|
|||||||
config_space: Vec<u8>,
|
config_space: Vec<u8>,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
ctrl_queue_epoll_thread: Option<thread::JoinHandle<result::Result<(), DeviceError>>>,
|
ctrl_queue_epoll_thread: Option<thread::JoinHandle<result::Result<(), DeviceError>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
queue_size: Vec<u16>,
|
queue_size: Vec<u16>,
|
||||||
@ -349,7 +349,7 @@ impl Net {
|
|||||||
config_space,
|
config_space,
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
ctrl_queue_epoll_thread: None,
|
ctrl_queue_epoll_thread: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
queue_size: vec![queue_size; queue_num],
|
queue_size: vec![queue_size; queue_num],
|
||||||
@ -520,7 +520,7 @@ impl VirtioDevice for Net {
|
|||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut epoll_thread = Vec::new();
|
let mut epoll_threads = Vec::new();
|
||||||
for _ in 0..taps.len() {
|
for _ in 0..taps.len() {
|
||||||
let rx = RxVirtio::new();
|
let rx = RxVirtio::new();
|
||||||
let tx = TxVirtio::new();
|
let tx = TxVirtio::new();
|
||||||
@ -550,14 +550,14 @@ impl VirtioDevice for Net {
|
|||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("virtio_net".to_string())
|
.name("virtio_net".to_string())
|
||||||
.spawn(move || handler.run(paused, queue_pair, queue_evt_pair))
|
.spawn(move || handler.run(paused, queue_pair, queue_evt_pair))
|
||||||
.map(|thread| epoll_thread.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);
|
||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_thread);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ pub struct Pmem {
|
|||||||
config: VirtioPmemConfig,
|
config: VirtioPmemConfig,
|
||||||
queue_evts: Option<Vec<EventFd>>,
|
queue_evts: Option<Vec<EventFd>>,
|
||||||
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
interrupt_cb: Option<Arc<dyn VirtioInterrupt>>,
|
||||||
epoll_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ impl Pmem {
|
|||||||
config,
|
config,
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -494,7 +494,7 @@ impl VirtioDevice for Pmem {
|
|||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_threads);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ pub struct Rng {
|
|||||||
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_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ impl Rng {
|
|||||||
acked_features: 0u64,
|
acked_features: 0u64,
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ impl VirtioDevice for Rng {
|
|||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_threads);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,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_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ impl Blk {
|
|||||||
queue_sizes: vec![vu_cfg.queue_size; vu_cfg.num_queues],
|
queue_sizes: vec![vu_cfg.queue_size; vu_cfg.num_queues],
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ impl VirtioDevice for Blk {
|
|||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_threads);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,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_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ impl Fs {
|
|||||||
slave_req_support,
|
slave_req_support,
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -430,7 +430,7 @@ impl VirtioDevice for Fs {
|
|||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_threads);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ 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_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
ctrl_queue_epoll_thread: Option<thread::JoinHandle<result::Result<(), CtrlError>>>,
|
ctrl_queue_epoll_thread: Option<thread::JoinHandle<result::Result<(), CtrlError>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ impl Net {
|
|||||||
queue_sizes: vec![vu_cfg.queue_size; queue_num],
|
queue_sizes: vec![vu_cfg.queue_size; queue_num],
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
ctrl_queue_epoll_thread: None,
|
ctrl_queue_epoll_thread: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
})
|
})
|
||||||
@ -307,7 +307,7 @@ impl VirtioDevice for Net {
|
|||||||
)
|
)
|
||||||
.map_err(ActivateError::VhostUserNetSetup)?;
|
.map_err(ActivateError::VhostUserNetSetup)?;
|
||||||
|
|
||||||
let mut epoll_thread = Vec::new();
|
let mut epoll_threads = Vec::new();
|
||||||
for _ in 0..vu_interrupt_list.len() / 2 {
|
for _ in 0..vu_interrupt_list.len() / 2 {
|
||||||
let mut interrupt_list_sub: Vec<(Option<EventFd>, Queue)> = Vec::with_capacity(2);
|
let mut interrupt_list_sub: Vec<(Option<EventFd>, Queue)> = Vec::with_capacity(2);
|
||||||
interrupt_list_sub.push(vu_interrupt_list.remove(0));
|
interrupt_list_sub.push(vu_interrupt_list.remove(0));
|
||||||
@ -325,14 +325,14 @@ impl VirtioDevice for Net {
|
|||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("vhost_user_net".to_string())
|
.name("vhost_user_net".to_string())
|
||||||
.spawn(move || handler.run(paused))
|
.spawn(move || handler.run(paused))
|
||||||
.map(|thread| epoll_thread.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);
|
||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_thread);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,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_thread: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
epoll_threads: Option<Vec<thread::JoinHandle<result::Result<(), DeviceError>>>>,
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ where
|
|||||||
acked_features: 0u64,
|
acked_features: 0u64,
|
||||||
queue_evts: None,
|
queue_evts: None,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
epoll_thread: None,
|
epoll_threads: None,
|
||||||
paused: Arc::new(AtomicBool::new(false)),
|
paused: Arc::new(AtomicBool::new(false)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ where
|
|||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.epoll_thread = Some(epoll_threads);
|
self.epoll_threads = Some(epoll_threads);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user