Skip to content

Commit 913a6c5

Browse files
committed
Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 91221d8 commit 913a6c5

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ tools/firecracker-builder-stamp: tools/docker/Dockerfile.firecracker-builder
290290
touch $@
291291

292292
$(FIRECRACKER_BIN) $(JAILER_BIN): $(FIRECRACKER_DIR)/Cargo.toml tools/firecracker-builder-stamp
293+
(cd $(FIRECRACKER_DIR) && patch -p1 < $(CURDIR)/seccomp.patch)
293294
docker run --rm -it --user $(UID) \
294295
--volume $(CURDIR)/$(FIRECRACKER_DIR):/src \
295296
--volume $(CARGO_CACHE_VOLUME_NAME):/usr/local/cargo/registry \

seccomp.patch

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

Comments
 (0)