From 96ae27069dba4f50c19ff0947a073ea45b880002 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Wed, 22 Apr 2026 21:44:59 +0200 Subject: [PATCH] ci/crosvm: Sanitize CROSVM_RET in crosvm-runner.sh When crosvm crashes, the `exit_code` file might not exist or might contain unexpected garbage (multi-line output or spaces). Because $CROSVM_RET was unquoted in comparisons, this led to intermittent "too many arguments" bash syntax errors, which masked the true failure. Signed-off-by: Valentine Burley Part-of: --- .gitlab-ci/crosvm-runner.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci/crosvm-runner.sh b/.gitlab-ci/crosvm-runner.sh index 0b3b514522f..903716c9b5e 100755 --- a/.gitlab-ci/crosvm-runner.sh +++ b/.gitlab-ci/crosvm-runner.sh @@ -150,15 +150,17 @@ crosvm --no-syslog run \ section_start crosvm_results "Processing crosvm results" CROSVM_RET=$? -[ ${CROSVM_RET} -eq 0 ] && { +[ "${CROSVM_RET}" -eq 0 ] && { # The actual return code is the crosvm guest script's exit code CROSVM_RET=$(cat ${VM_TEMP_DIR}/exit_code 2>/dev/null) + # Sanitize it to a single integer + CROSVM_RET=$(echo "$CROSVM_RET" | grep -o '^[0-9]\+' | head -n 1) # Force error when the guest script's exit code is not available CROSVM_RET=${CROSVM_RET:-1} } # Show crosvm output on error to help with debugging -[ ${CROSVM_RET} -eq 0 ] || { +[ "${CROSVM_RET}" -eq 0 ] || { { set +x; } 2>/dev/null echo "Dumping crosvm output.." >&2 cat ${VM_TEMP_DIR}/crosvm >&2