1#!/bin/sh 2 3set -e 4 5VSOCK_STDOUT=$1 6VSOCK_STDERR=$2 7VM_TEMP_DIR=$3 8 9mount -t proc none /proc 10mount -t sysfs none /sys 11mkdir -p /dev/pts 12mount -t devpts devpts /dev/pts 13mount -t tmpfs tmpfs /tmp 14 15. ${VM_TEMP_DIR}/crosvm-env.sh 16 17# .gitlab-ci.yml script variable is using relative paths to install directory, 18# so change to that dir before running `crosvm-script` 19cd "${CI_PROJECT_DIR}" 20 21# The exception is the dEQP binary, as it needs to run from its own directory 22[ -z "${DEQP_BIN_DIR}" ] || cd "${DEQP_BIN_DIR}" 23 24# Use a FIFO to collect relevant error messages 25STDERR_FIFO=/tmp/crosvm-stderr.fifo 26mkfifo -m 600 ${STDERR_FIFO} 27 28dmesg --level crit,err,warn -w > ${STDERR_FIFO} & 29DMESG_PID=$! 30 31# Transfer the errors and crosvm-script output via a pair of virtio-vsocks 32socat -d -u pipe:${STDERR_FIFO} vsock-listen:${VSOCK_STDERR} & 33socat -d -U vsock-listen:${VSOCK_STDOUT} \ 34 system:"stdbuf -eL sh ${VM_TEMP_DIR}/crosvm-script.sh 2> ${STDERR_FIFO}; echo \$? > ${VM_TEMP_DIR}/exit_code",nofork 35 36kill ${DMESG_PID} 37wait 38 39sync 40poweroff -d -n -f || true 41 42sleep 1 # Just in case init would exit before the kernel shuts down the VM 43