This repository was archived by the owner on Apr 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +62
-1
lines changed Expand file tree Collapse file tree 4 files changed +62
-1
lines changed Original file line number Diff line number Diff line change
1
+ FROM public.ecr.aws/docker/library/rust:1.72.0-slim-bookworm as rust-builder
2
+
3
+ WORKDIR /src/
4
+
5
+ COPY ./Cargo.toml ./Cargo.lock ./
6
+ COPY ./src src/
7
+
8
+ RUN cargo build --locked --release
9
+
10
+ FROM public.ecr.aws/docker/library/debian:12.1-slim
11
+
12
+ RUN apt update && apt install -y procps
13
+
14
+ COPY start.sh /usr/local/bin
15
+ RUN chmod +x /usr/local/bin/start.sh
16
+
17
+ COPY --from=rust-builder /src/target/release/vsock-experiment /usr/local/bin/
18
+
19
+ CMD ["/usr/local/bin/start.sh" ]
Original file line number Diff line number Diff line change
1
+ all : run
2
+
3
+ install-relay :
4
+ cargo install vsock-relay
5
+
6
+ run-relay :
7
+ vsock-relay -s 0.0.0.0:8080 -l 4:8080
8
+
9
+ build : src/* .rs Cargo.toml Dockerfile
10
+ docker build -t vsock-experiment .
11
+ nitro-cli build-enclave --docker-uri vsock-experiment:latest --output-file vsock-experiment.eif
12
+
13
+ run : build
14
+ nitro-cli terminate-enclave --all
15
+ nitro-cli run-enclave \
16
+ --cpu-count 8 \
17
+ --memory 512 \
18
+ --enclave-cid 4 \
19
+ --eif-path " vsock-experiment.eif" \
20
+ --debug-mode \
21
+ --attach-console
Original file line number Diff line number Diff line change 1
1
use futures:: StreamExt ;
2
+ use std:: net:: Shutdown ;
3
+ use std:: process:: exit;
4
+ use std:: time:: Duration ;
2
5
use tokio:: io:: AsyncWriteExt ;
6
+ use tokio:: time:: sleep;
3
7
use tokio_vsock:: VsockListener ;
4
8
5
9
#[ tokio:: main]
6
10
async fn main ( ) {
7
- let listener = VsockListener :: bind ( 4 , 1234 ) . expect ( "Failed to bind to address" ) ;
11
+ let listener = VsockListener :: bind ( 4 , 8080 ) . expect ( "Failed to bind to address" ) ;
12
+
13
+ tokio:: spawn ( async {
14
+ sleep ( Duration :: from_secs ( 30 ) ) . await ;
15
+ println ! ( "I'm out!" ) ;
16
+ exit ( 0 ) ;
17
+ } ) ;
8
18
9
19
let mut incoming = listener. incoming ( ) ;
10
20
while let Some ( result) = incoming. next ( ) . await {
@@ -13,6 +23,7 @@ async fn main() {
13
23
let response = "HTTP/1.1 200 OK\r \n Content-Type: text/plain\r \n \r \n Hello, World!" ;
14
24
15
25
stream. write_all ( response. as_bytes ( ) ) . await . ok ( ) ;
26
+ stream. shutdown ( Shutdown :: Both ) . ok ( ) ;
16
27
} ) ;
17
28
}
18
29
}
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sh -c ' while true; do top -b -n 1 -o %MEM | head -n 13; sleep 2; done' &
4
+ # sh -c 'while true; do cat /proc/meminfo; sleep 10; done' &
5
+ # sh -c 'while true; do slabtop -o; sleep 10; done' &
6
+ # sh -c 'while true; do cat /proc/meminfo; slabtop -o; echo "alloc calls:"; cat /sys/kernel/slab/kmalloc-4096/alloc_calls; echo "free calls:"; cat /sys/kernel/slab/kmalloc-4096/free_calls; echo 3 > /proc/sys/vm/drop_caches; sleep 10; done' &
7
+
8
+ vsock-experiment &
9
+
10
+ sleep infinity
You can’t perform that action at this time.
0 commit comments