|
| 1 | +diff --git a/src/vmm/src/vstate.rs b/src/vmm/src/vstate.rs |
| 2 | +index f49d1e53..7dd8d700 100644 |
| 3 | +--- a/src/vmm/src/vstate.rs |
| 4 | ++++ b/src/vmm/src/vstate.rs |
| 5 | +@@ -792,8 +792,10 @@ impl Vcpu { |
| 6 | + error!("Failed signaling vcpu exit event: {}", e); |
| 7 | + } |
| 8 | + } |
| 9 | +- // State machine reached its end. |
| 10 | +- StateMachine::finish(Self::exited) |
| 11 | ++ // State machine reached its end, but move to 'paused' state |
| 12 | ++ // to keep the thread, since thread cleanup on libc may call |
| 13 | ++ // syscalls which we don't want to whitelist (#1456) |
| 14 | ++ StateMachine::next(Self::paused) |
| 15 | + } |
| 16 | + } |
| 17 | + |
| 18 | +@@ -1245,13 +1247,17 @@ mod tests { |
| 19 | + // Stop it by sending exit. |
| 20 | + assert!(vcpu_handle.send_event(VcpuEvent::Exit).is_ok()); |
| 21 | + |
| 22 | +- // Validate vCPU thread ends execution. |
| 23 | +- vcpu_handle |
| 24 | +- .join_vcpu_thread() |
| 25 | +- .expect("failed to join thread"); |
| 26 | +- |
| 27 | +- // Validate that the vCPU signaled its exit. |
| 28 | +- assert_eq!(vcpu_exit_evt.read().unwrap(), 1); |
| 29 | ++ // Sending exit won't stop the thread. |
| 30 | ++ // Instead of waiting the completion of the thread, we need to poll the fd. |
| 31 | ++ for _i in 0..10 { |
| 32 | ++ match vcpu_exit_evt.read() { |
| 33 | ++ Ok(x) => assert_eq!(x, 1), |
| 34 | ++ Err(e) if e.kind() == io::ErrorKind::WouldBlock => { |
| 35 | ++ thread::sleep(Duration::from_millis(100)) |
| 36 | ++ } |
| 37 | ++ Err(e) => panic!("failed to read the exit event: {}", e), |
| 38 | ++ } |
| 39 | ++ } |
| 40 | + } |
| 41 | + |
| 42 | + #[test] |
0 commit comments