This commit is contained in:
Kroese 2023-04-22 18:32:19 +02:00 committed by GitHub
parent e3f9b5a6db
commit 76d49f5b02

View file

@ -3,8 +3,8 @@ set -eu
# Docker environment variabeles # Docker environment variabeles
: ${BOOT:=''}. # URL of the ISO file : ${BOOT:=''} # URL of the ISO file
: ${DEBUG:=''}. # Enable debug mode : ${DEBUG:='N'} # Enable debug mode
: ${ALLOCATE:='Y'} # Preallocate diskspace : ${ALLOCATE:='Y'} # Preallocate diskspace
: ${CPU_CORES:='1'} # Amount of CPU cores : ${CPU_CORES:='1'} # Amount of CPU cores
: ${DISK_SIZE:='16G'} # Initial data disk size : ${DISK_SIZE:='16G'} # Initial data disk size
@ -13,6 +13,8 @@ set -eu
echo "Starting QEMU for Docker v${VERSION}..." echo "Starting QEMU for Docker v${VERSION}..."
STORAGE="/storage" STORAGE="/storage"
KERNEL=$(uname -r | cut -b 1)
[ ! -d "$STORAGE" ] && echo "Storage folder (${STORAGE}) not found!" && exit 69 [ ! -d "$STORAGE" ] && echo "Storage folder (${STORAGE}) not found!" && exit 69
[ ! -f "/run/run.sh" ] && echo "Script must run inside Docker container!" && exit 60 [ ! -f "/run/run.sh" ] && echo "Script must run inside Docker container!" && exit 60
@ -48,7 +50,14 @@ RAM_OPTS=$(echo "-m ${RAM_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
CPU_OPTS="-smp ${CPU_CORES},sockets=1,cores=${CPU_CORES},threads=1" CPU_OPTS="-smp ${CPU_CORES},sockets=1,cores=${CPU_CORES},threads=1"
SERIAL_OPTS="-serial mon:stdio -device virtio-serial-pci,id=virtio-serial0,bus=pcie.0,addr=0x3" SERIAL_OPTS="-serial mon:stdio -device virtio-serial-pci,id=virtio-serial0,bus=pcie.0,addr=0x3"
EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0 -object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0" EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0 -object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0"
ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${KVM_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS}" ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${KVM_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS}"
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')
if [ "$DEBUG" = "Y" ]; then
echo -n "qemu-system-x86_64 "
echo "${ARGS}" && echo
fi
set -m set -m
( (
@ -56,4 +65,8 @@ set -m
) )
set +m set +m
pidwait -F "${_QEMU_PID}" & wait $! if (( KERNEL > 4 )); then
pidwait -F "${_QEMU_PID}" & wait $!
else
tail --pid "$(cat ${_QEMU_PID})" --follow /dev/null & wait $!
fi