From b2de1cd523be388c1f7806f58eaafdb46adf3d7a Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 20 Apr 2020 17:24:31 +0200 Subject: [PATCH] vm-virtio: Implement shutdown() for virtio-fs Since the virtio-fs device is backed by a vhost-user process, it is important to implement the proper shutdown() function from the VirtioDevice trait, as vhost-user-blk and vhost-user-net do. Signed-off-by: Sebastien Boeuf --- vm-virtio/src/vhost_user/fs.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vm-virtio/src/vhost_user/fs.rs b/vm-virtio/src/vhost_user/fs.rs index 14631184a..e8debdf5e 100644 --- a/vm-virtio/src/vhost_user/fs.rs +++ b/vm-virtio/src/vhost_user/fs.rs @@ -13,7 +13,7 @@ use libc::{self, c_void, off64_t, pread64, pwrite64, EFD_NONBLOCK}; use std::cmp; use std::io; use std::io::Write; -use std::os::unix::io::RawFd; +use std::os::unix::io::{AsRawFd, RawFd}; use std::result; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; @@ -544,6 +544,10 @@ impl VirtioDevice for Fs { )) } + fn shutdown(&mut self) { + let _ = unsafe { libc::close(self.vu.as_raw_fd()) }; + } + fn get_shm_regions(&self) -> Option { if let Some(cache) = self.cache.as_ref() { Some(cache.0.clone())