mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Introduce WorkerThreads handle
Take the recent thread refactor further. Bundle a device's worker JoinHandles together with the kill event that stops them into a single WorkerThreads value, owned by VirtioCommon. Its Drop signals the workers to exit, unparks any parked for migration, and joins them. This makes a detached/leaked worker unrepresentable. reset(), wait_for_epoll_threads() and VhostUserCommon::shutdown() now happen when dropping the WorkerThreads, and the unpark-before-join teardown now lives in one place. Assisted-by: Claude:Opus-4.8 Signed-off-by: Dylan Reid <dgreid@fb.com> Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -426,19 +426,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> Drop for Vsock<B>
|
||||
where
|
||||
B: VsockBackend,
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
if let Some(kill_evt) = self.common.kill_evt.take() {
|
||||
// Ignore the result because there is nothing we can do about it.
|
||||
let _ = kill_evt.write(1);
|
||||
}
|
||||
self.common.wait_for_epoll_threads();
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> VirtioDevice for Vsock<B>
|
||||
where
|
||||
B: VsockBackend + Sync + 'static,
|
||||
|
||||
Reference in New Issue
Block a user