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:
Dylan Reid
2026-05-29 20:30:23 -07:00
committed by Rob Bradford
parent 815a1f0801
commit 2bcacbe19d
13 changed files with 158 additions and 191 deletions

View File

@@ -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,