mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
crosvm: with vcpus > 1 cleanly shutdown jailed processes
When creating a new vcpu, setup_vcpu() returns a JoinHandle which allows the main thread to wait for the vcpu threads to complete. Put this handle into a vector from which it will be later join()ed with to wait for its execution to complete. By ensuring that the thread's completion is waited for all the references to the ProxyDevice will be dropped and thus the jailed processes will be sent a shutdown message and they will cleanly exit. TEST="crosvm run --cpus=2 ..." and observe that the jailed processes are cleanly shutdown and not forcefully killed. BUG=812234 Signed-off-by: Rob Bradford <robert.bradford@intel.com> Change-Id: I771251ff1cdf762ca68c0781dc7de9f95cc1fcfe Reviewed-on: https://chromium-review.googlesource.com/919165 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
parent
30ebd272d6
commit
8091a2a525
1 changed files with 3 additions and 2 deletions
|
@ -757,11 +757,11 @@ pub fn run_config(cfg: Config) -> Result<()> {
|
|||
kernel_image,
|
||||
&CString::new(cmdline).unwrap())?;
|
||||
|
||||
let vcpu_handles = Vec::with_capacity(vcpu_count as usize);
|
||||
let mut vcpu_handles = Vec::with_capacity(vcpu_count as usize);
|
||||
let vcpu_thread_barrier = Arc::new(Barrier::new((vcpu_count + 1) as usize));
|
||||
for cpu_id in 0..vcpu_count {
|
||||
let exit_evt = exit_evt.try_clone().map_err(Error::CloneEventFd)?;
|
||||
setup_vcpu(&kvm,
|
||||
let vcpu_handle = setup_vcpu(&kvm,
|
||||
&vm,
|
||||
cpu_id,
|
||||
vcpu_count,
|
||||
|
@ -770,6 +770,7 @@ pub fn run_config(cfg: Config) -> Result<()> {
|
|||
kill_signaled.clone(),
|
||||
io_bus.clone(),
|
||||
mmio_bus.clone())?;
|
||||
vcpu_handles.push(vcpu_handle);
|
||||
}
|
||||
vcpu_thread_barrier.wait();
|
||||
|
||||
|
|
Loading…
Reference in a new issue