diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2019-09-12 13:31:30 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-17 22:32:21 +0000 |
commit | 94c352752e1109fc6cf7c0cf9c6ce121ad1d46b9 (patch) | |
tree | 01c3d76b91b9da9c86e777f5d65286177e63ec14 | |
parent | 039b6727ba1cc31f322803392f0065dd3839a67d (diff) | |
download | crosvm-94c352752e1109fc6cf7c0cf9c6ce121ad1d46b9.tar crosvm-94c352752e1109fc6cf7c0cf9c6ce121ad1d46b9.tar.gz crosvm-94c352752e1109fc6cf7c0cf9c6ce121ad1d46b9.tar.bz2 crosvm-94c352752e1109fc6cf7c0cf9c6ce121ad1d46b9.tar.lz crosvm-94c352752e1109fc6cf7c0cf9c6ce121ad1d46b9.tar.xz crosvm-94c352752e1109fc6cf7c0cf9c6ce121ad1d46b9.tar.zst crosvm-94c352752e1109fc6cf7c0cf9c6ce121ad1d46b9.zip |
linux: drop VM before exiting to allow cleanup
Clean up the `linux` object (which contains the devices) before the control sockets passed to `run_control` are closed. This allows crosvm to shut down cleanly without any error messages about short reads from the control sockets. BUG=chromium:992494 TEST=exit crosvm without errors Change-Id: I1040c2f9ecbd03f820c7082da3327962ecc445f1 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1802155 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
-rw-r--r-- | src/linux.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/linux.rs b/src/linux.rs index 7ce7c82..58e0971 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -10,6 +10,7 @@ use std::ffi::CStr; use std::fmt::{self, Display}; use std::fs::{File, OpenOptions}; use std::io::{self, stdin, Read}; +use std::mem; use std::net::Ipv4Addr; #[cfg(feature = "gpu")] use std::num::NonZeroU8; @@ -1517,7 +1518,8 @@ fn run_control( let vcpu_thread_barrier = Arc::new(Barrier::new(linux.vcpus.len() + 1)); let run_mode_arc = Arc::new(VcpuRunMode::default()); setup_vcpu_signal_handler()?; - for (cpu_id, vcpu) in linux.vcpus.into_iter().enumerate() { + let vcpus = linux.vcpus.split_off(0); + for (cpu_id, vcpu) in vcpus.into_iter().enumerate() { let handle = run_vcpu( vcpu, cpu_id as u32, @@ -1804,6 +1806,10 @@ fn run_control( } } + // Explicitly drop the VM structure here to allow the devices to clean up before the + // control sockets are closed when this function exits. + mem::drop(linux); + stdin_lock .set_canon_mode() .expect("failed to restore canonical mode for terminal"); |