Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Display config #519

Merged
merged 9 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/config.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
#!/usr/bin/env bash
set -Eeuo pipefail

DEF_OPTS="-nographic -nodefaults -boot strict=on -display none"
DEF_OPTS="-nodefaults -boot strict=on"
RAM_OPTS=$(echo "-m $RAM_SIZE" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
CPU_OPTS="-cpu $CPU_MODEL -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1"
MAC_OPTS="-machine type=q35,usb=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
EXTRA_OPTS="$EXTRA_OPTS -object rng-random,id=objrng0,filename=/dev/urandom"
EXTRA_OPTS="$EXTRA_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c"
DEV_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
DEV_OPTS="$DEV_OPTS -object rng-random,id=objrng0,filename=/dev/urandom"
DEV_OPTS="$DEV_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c"

if [[ "$GPU" == [Yy1]* ]] && [[ "$ARCH" == "amd64" ]]; then
DEF_OPTS="-nodefaults -boot strict=on -display egl-headless,rendernode=/dev/dri/renderD128"
DEF_OPTS="$DEF_OPTS -device virtio-vga,id=video0,max_outputs=1,bus=pcie.0,addr=0x1"
fi

[[ "$CONSOLE" != [Yy]* ]] && DEF_OPTS="$DEF_OPTS -daemonize -D $QEMU_LOG"

ARGS="$DEF_OPTS $CPU_OPTS $RAM_OPTS $MAC_OPTS $MON_OPTS $SERIAL_OPTS $NET_OPTS $DISK_OPTS $EXTRA_OPTS $ARGUMENTS"
ARGS="$DEF_OPTS $CPU_OPTS $RAM_OPTS $MAC_OPTS $DISPLAY_OPTS $MON_OPTS $SERIAL_OPTS $NET_OPTS $DISK_OPTS $DEV_OPTS $ARGUMENTS"
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')

return 0
1 change: 1 addition & 0 deletions src/cpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -Eeuo pipefail

# Docker environment variables

: ${KVM:='Y'}
: ${HOST_CPU:=''}
: ${CPU_MODEL:='host'}
: ${CPU_FEATURES:='+ssse3,+sse4.1,+sse4.2'}
Expand Down
17 changes: 17 additions & 0 deletions src/gpu.sh → src/display.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# Docker environment variables

: ${GPU:='N'} # GPU passthrough
: ${DISPLAY:='none'} # Display type

case "${DISPLAY,,}" in
vnc)
DISPLAY_OPTS="-display vnc=:0 -vga virtio"
;;
*)
DISPLAY_OPTS="-display $DISPLAY -vga none"
;;
esac

if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then
return 0
fi

DISPLAY_OPTS="-display egl-headless,rendernode=/dev/dri/renderD128 -vga virtio"
[[ "${DISPLAY,,}" == "vnc" ]] && DISPLAY_OPTS="$DISPLAY_OPTS -vnc :0"

[ ! -d /dev/dri ] && mkdir -m 755 /dev/dri

if [ ! -c /dev/dri/card0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion src/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ cd /run
. reset.sh # Initialize system
. install.sh # Run installation
. disk.sh # Initialize disks
. display.sh # Initialize graphics
. network.sh # Initialize network
. gpu.sh # Initialize graphics
. cpu.sh # Initialize processor
. serial.sh # Initialize serialport
. power.sh # Configure shutdown
Expand Down
12 changes: 9 additions & 3 deletions src/power.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ _graceful_shutdown() {
finish "$code" && return "$code"
}

MON_OPTS="\
-pidfile $QEMU_PID \
-monitor telnet:localhost:$QEMU_PORT,server,nowait,nodelay"

if [[ "$CONSOLE" != [Yy]* ]]; then

MON_OPTS="$MON_OPTS -daemonize -D $QEMU_LOG"

_trap _graceful_shutdown SIGTERM SIGHUP SIGINT SIGABRT SIGQUIT

fi

MON_OPTS="\
-pidfile $QEMU_PID \
-monitor telnet:localhost:$QEMU_PORT,server,nowait,nodelay"
return 0
2 changes: 0 additions & 2 deletions src/reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR
# Docker environment variables

: ${TZ:=''} # System local timezone
: ${GPU:='N'} # Disable GPU passthrough
: ${KVM:='Y'} # Enable KVM acceleration
: ${DEBUG:='N'} # Disable debugging mode
: ${COUNTRY:=''} # Country code for mirror
: ${CONSOLE:='N'} # Disable console mode
Expand Down