2021-02-04 22:14:26 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-09-08 13:52:58 +08:00
|
|
|
set -e
|
|
|
|
|
2022-02-09 04:48:39 +08:00
|
|
|
VSOCK_STDOUT=$1
|
|
|
|
VSOCK_STDERR=$2
|
|
|
|
VSOCK_TEMP_DIR=$3
|
2021-02-04 22:14:26 +08:00
|
|
|
|
|
|
|
mount -t proc none /proc
|
|
|
|
mount -t sysfs none /sys
|
|
|
|
mkdir -p /dev/pts
|
|
|
|
mount -t devpts devpts /dev/pts
|
|
|
|
mount -t tmpfs tmpfs /tmp
|
|
|
|
|
2022-02-09 04:48:39 +08:00
|
|
|
. ${VSOCK_TEMP_DIR}/crosvm-env.sh
|
2021-02-04 22:14:26 +08:00
|
|
|
|
2022-01-15 05:43:08 +08:00
|
|
|
# .gitlab-ci.yml script variable is using relative paths to install directory,
|
|
|
|
# so change to that dir before running `crosvm-script`
|
|
|
|
cd "${CI_PROJECT_DIR}"
|
|
|
|
|
2022-02-09 04:48:39 +08:00
|
|
|
# The exception is the dEQP binary, as it needs to run from its own directory
|
|
|
|
[ -z "${DEQP_BIN_DIR}" ] || cd "${DEQP_BIN_DIR}"
|
2021-02-04 22:14:26 +08:00
|
|
|
|
2022-02-09 04:48:39 +08:00
|
|
|
# Use a FIFO to collect relevant error messages
|
|
|
|
STDERR_FIFO=/tmp/crosvm-stderr.fifo
|
|
|
|
mkfifo -m 600 ${STDERR_FIFO}
|
2021-02-04 22:14:26 +08:00
|
|
|
|
2022-02-09 04:48:39 +08:00
|
|
|
dmesg --level crit,err,warn -w > ${STDERR_FIFO} &
|
|
|
|
DMESG_PID=$!
|
2021-08-06 16:28:36 +08:00
|
|
|
|
2022-02-09 04:48:39 +08:00
|
|
|
# Transfer the errors and crosvm-script output via a pair of virtio-vsocks
|
|
|
|
socat -d -u pipe:${STDERR_FIFO} vsock-listen:${VSOCK_STDERR} &
|
|
|
|
socat -d -U vsock-listen:${VSOCK_STDOUT} \
|
|
|
|
system:"stdbuf -eL sh ${VSOCK_TEMP_DIR}/crosvm-script.sh 2> ${STDERR_FIFO}; echo \$? > ${VSOCK_TEMP_DIR}/exit_code",nofork
|
2021-02-04 22:14:26 +08:00
|
|
|
|
2022-02-09 04:48:39 +08:00
|
|
|
kill ${DMESG_PID}
|
|
|
|
wait
|
|
|
|
|
|
|
|
sync
|
2021-09-08 13:52:58 +08:00
|
|
|
poweroff -d -n -f || true
|
2021-02-04 22:14:26 +08:00
|
|
|
|
2021-09-08 13:52:58 +08:00
|
|
|
sleep 1 # Just in case init would exit before the kernel shuts down the VM
|