mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: properly join all threads on Drop
This change is important to do a proper resource cleanup. We decided
to do this repetitive approach as VirtioCommon can't implement Drop
without major changes to the corresponding code. Also, devices such as
Net can't easily use the epoll_threads-abstraction from VirtioCommon as
it has multiple threads with different semantics.
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
(cherry picked from commit ad6c0ee52b)
This commit is contained in:
committed by
Bo Chen
parent
8dd4d42053
commit
1adfb7e9f8
@@ -215,6 +215,12 @@ impl Drop for Blk {
|
||||
error!("failed to kill vhost-user-blk: {:?}", e);
|
||||
}
|
||||
}
|
||||
self.common.wait_for_epoll_threads();
|
||||
if let Some(thread) = self.epoll_thread.take() {
|
||||
if let Err(e) = thread.join() {
|
||||
error!("Error joining thread: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -451,6 +451,12 @@ impl Drop for Fs {
|
||||
// Ignore the result because there is nothing we can do about it.
|
||||
let _ = kill_evt.write(1);
|
||||
}
|
||||
self.common.wait_for_epoll_threads();
|
||||
if let Some(thread) = self.epoll_thread.take() {
|
||||
if let Err(e) = thread.join() {
|
||||
error!("Error joining thread: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -231,6 +231,19 @@ impl Drop for Net {
|
||||
error!("failed to kill vhost-user-net: {:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
self.common.wait_for_epoll_threads();
|
||||
|
||||
if let Some(thread) = self.epoll_thread.take() {
|
||||
if let Err(e) = thread.join() {
|
||||
error!("Error joining thread: {:?}", e);
|
||||
}
|
||||
}
|
||||
if let Some(thread) = self.ctrl_queue_epoll_thread.take() {
|
||||
if let Err(e) = thread.join() {
|
||||
error!("Error joining thread: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user