mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Use VirtioCommon::spawn_worker()
Replace use of spawn_virtio_thread() helper with the new method on VirtioCommon to handle thread management as well as spawning. As a result this cleanly handles reset if it fails to spawn the thread. Assisted-by: Claude:Opus-4.7 Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -41,7 +41,6 @@ use super::{
|
||||
VirtioDeviceType, VirtioInterruptType,
|
||||
};
|
||||
use crate::seccomp_filters::Thread;
|
||||
use crate::thread_helper::spawn_virtio_thread;
|
||||
use crate::{GuestMemoryMmap, VirtioInterrupt};
|
||||
|
||||
/// Control queue
|
||||
@@ -697,8 +696,6 @@ impl VirtioDevice for Net {
|
||||
let qp_threads = (num_queues - ctrl_threads) / 2;
|
||||
self.common.paused_sync = Some(Arc::new(Barrier::new(1 + qp_threads + ctrl_threads)));
|
||||
|
||||
let mut epoll_threads = Vec::new();
|
||||
|
||||
if has_ctrl_queue {
|
||||
let ctrl_queue_index = num_queues - 1;
|
||||
let (_, mut ctrl_queue, ctrl_queue_evt) = queues.remove(ctrl_queue_index);
|
||||
@@ -721,11 +718,10 @@ impl VirtioDevice for Net {
|
||||
let paused = self.common.paused.clone();
|
||||
let paused_sync = self.common.paused_sync.clone();
|
||||
|
||||
spawn_virtio_thread(
|
||||
self.common.spawn_worker(
|
||||
&format!("{}_ctrl", self.id),
|
||||
&self.seccomp_action,
|
||||
Thread::VirtioNetCtl,
|
||||
&mut epoll_threads,
|
||||
&self.exit_evt,
|
||||
self.device_status.clone(),
|
||||
interrupt_cb.clone(),
|
||||
@@ -798,11 +794,10 @@ impl VirtioDevice for Net {
|
||||
let paused = self.common.paused.clone();
|
||||
let paused_sync = self.common.paused_sync.clone();
|
||||
|
||||
spawn_virtio_thread(
|
||||
self.common.spawn_worker(
|
||||
&format!("{}_qp{}", self.id.clone(), i),
|
||||
&self.seccomp_action,
|
||||
Thread::VirtioNet,
|
||||
&mut epoll_threads,
|
||||
&self.exit_evt,
|
||||
self.device_status.clone(),
|
||||
interrupt_cb.clone(),
|
||||
@@ -810,8 +805,6 @@ impl VirtioDevice for Net {
|
||||
)?;
|
||||
}
|
||||
|
||||
self.common.epoll_threads = Some(epoll_threads);
|
||||
|
||||
event!("virtio-device", "activated", "id", &self.id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user