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