mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Reuse common shutdown code in drop implementations
Now that the VhostUserCommon::shutdown implementation has been filled out to support migration it can also be used for the drop implementations in the vhost-user devices. It's worth noting that the call to wait_for_epoll_threads() was a no-op as those threads are only configured on conventional virtio devices. Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -202,17 +202,7 @@ impl Blk {
|
||||
|
||||
impl Drop for Blk {
|
||||
fn drop(&mut self) {
|
||||
if let Some(kill_evt) = self.vu_common.virtio_common.kill_evt.take()
|
||||
&& let Err(e) = kill_evt.write(1)
|
||||
{
|
||||
error!("failed to kill vhost-user-blk: {e:?}");
|
||||
}
|
||||
self.vu_common.virtio_common.wait_for_epoll_threads();
|
||||
if let Some(thread) = self.vu_common.epoll_thread.take()
|
||||
&& let Err(e) = thread.join()
|
||||
{
|
||||
error!("Error joining thread: {e:?}");
|
||||
}
|
||||
self.vu_common.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,16 +211,7 @@ impl Fs {
|
||||
|
||||
impl Drop for Fs {
|
||||
fn drop(&mut self) {
|
||||
if let Some(kill_evt) = self.vu_common.virtio_common.kill_evt.take() {
|
||||
// Ignore the result because there is nothing we can do about it.
|
||||
let _ = kill_evt.write(1);
|
||||
}
|
||||
self.vu_common.virtio_common.wait_for_epoll_threads();
|
||||
if let Some(thread) = self.vu_common.epoll_thread.take()
|
||||
&& let Err(e) = thread.join()
|
||||
{
|
||||
error!("Error joining thread: {e:?}");
|
||||
}
|
||||
self.vu_common.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,16 +186,7 @@ space access. Reads will return 0xFF and writes will be ignored."
|
||||
|
||||
impl Drop for GenericVhostUser {
|
||||
fn drop(&mut self) {
|
||||
if let Some(kill_evt) = self.vu_common.virtio_common.kill_evt.take() {
|
||||
// Ignore the result because there is nothing we can do about it.
|
||||
let _ = kill_evt.write(1);
|
||||
}
|
||||
self.vu_common.virtio_common.wait_for_epoll_threads();
|
||||
if let Some(thread) = self.vu_common.epoll_thread.take()
|
||||
&& let Err(e) = thread.join()
|
||||
{
|
||||
error!("Error joining thread: {e:?}");
|
||||
}
|
||||
self.vu_common.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -231,19 +231,7 @@ impl Net {
|
||||
|
||||
impl Drop for Net {
|
||||
fn drop(&mut self) {
|
||||
if let Some(kill_evt) = self.vu_common.virtio_common.kill_evt.take()
|
||||
&& let Err(e) = kill_evt.write(1)
|
||||
{
|
||||
error!("failed to kill vhost-user-net: {e:?}");
|
||||
}
|
||||
|
||||
self.vu_common.virtio_common.wait_for_epoll_threads();
|
||||
|
||||
if let Some(thread) = self.vu_common.epoll_thread.take()
|
||||
&& let Err(e) = thread.join()
|
||||
{
|
||||
error!("Error joining thread: {e:?}");
|
||||
}
|
||||
self.vu_common.shutdown();
|
||||
|
||||
if let Some(thread) = self.ctrl_queue_epoll_thread.take()
|
||||
&& let Err(e) = thread.join()
|
||||
|
||||
Reference in New Issue
Block a user