From ac85d5fe58183f9a48f18e011e80317ca93e0864 Mon Sep 17 00:00:00 2001 From: panxiao81 Date: Wed, 16 Sep 2026 16:44:05 +0000 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8C=20microVM=20Runner=20?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=AE=8C=E6=88=90=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/gitea-microvm-guest-runner | 1 + scripts/microvm-runner-launch | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/gitea-microvm-guest-runner b/scripts/gitea-microvm-guest-runner index cee427f..3b4d076 100755 --- a/scripts/gitea-microvm-guest-runner +++ b/scripts/gitea-microvm-guest-runner @@ -27,3 +27,4 @@ gitea-runner register \ --token-file "$token_file" rm -f -- "$token_file" gitea-runner daemon --config "$config_file" --once +echo gitea-runner-job-complete >/dev/ttyS0 diff --git a/scripts/microvm-runner-launch b/scripts/microvm-runner-launch index 558f232..ff3865b 100755 --- a/scripts/microvm-runner-launch +++ b/scripts/microvm-runner-launch @@ -29,8 +29,13 @@ tap="mvr${instance_id%%-*}" overlay="$vm_dir/root.qcow2" seed="$vm_dir/seed.img" serial="$vm_dir/serial.log" +log_dir="$state_root/logs" cleanup() { + if test -f "$serial"; then + install -d -m 0700 "$log_dir" + cp "$serial" "$log_dir/$instance_id.log" + fi ip link delete "$tap" 2>/dev/null || true rm -rf -- "$vm_dir" } @@ -66,12 +71,16 @@ ip tuntap add dev "$tap" mode tap ip link set "$tap" master "$bridge" ip link set "$tap" up -timeout --signal=TERM --kill-after=30s "$vm_timeout" "$cloud_hypervisor" \ - --firmware "$firmware" \ - --cpus "boot=$cpus" \ - --memory "size=$memory" \ - --disk "path=$overlay,image_type=qcow2" \ - --disk "path=$seed,readonly=on,image_type=raw" \ - --net "tap=$tap,mac=$mac" \ - --serial "file=$serial" \ - --console off +if timeout --signal=TERM --kill-after=30s "$vm_timeout" "$cloud_hypervisor" \ + --firmware "$firmware" \ + --cpus "boot=$cpus" \ + --memory "size=$memory" \ + --disk "path=$overlay,image_type=qcow2" \ + --disk "path=$seed,readonly=on,image_type=raw" \ + --net "tap=$tap,mac=$mac" \ + --serial "file=$serial" \ + --console off; then + grep -Fq gitea-runner-job-complete "$serial" +else + exit $? +fi