diff --git a/virtio-devices/src/vhost_user/blk.rs b/virtio-devices/src/vhost_user/blk.rs index 529eb517d..8221b7b50 100644 --- a/virtio-devices/src/vhost_user/blk.rs +++ b/virtio-devices/src/vhost_user/blk.rs @@ -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(); } } diff --git a/virtio-devices/src/vhost_user/fs.rs b/virtio-devices/src/vhost_user/fs.rs index 71859365e..967fdecf9 100644 --- a/virtio-devices/src/vhost_user/fs.rs +++ b/virtio-devices/src/vhost_user/fs.rs @@ -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(); } } diff --git a/virtio-devices/src/vhost_user/generic_vhost_user.rs b/virtio-devices/src/vhost_user/generic_vhost_user.rs index 83f3fe465..177883443 100644 --- a/virtio-devices/src/vhost_user/generic_vhost_user.rs +++ b/virtio-devices/src/vhost_user/generic_vhost_user.rs @@ -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(); } } diff --git a/virtio-devices/src/vhost_user/net.rs b/virtio-devices/src/vhost_user/net.rs index 7cd4e4207..1c85b5f38 100644 --- a/virtio-devices/src/vhost_user/net.rs +++ b/virtio-devices/src/vhost_user/net.rs @@ -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()