feat: Verify clock source (#203)
This commit is contained in:
parent
36cd38da73
commit
120171e826
3 changed files with 37 additions and 39 deletions
49
src/boot.sh
49
src/boot.sh
|
@ -2,23 +2,14 @@
|
|||
set -Eeuo pipefail
|
||||
|
||||
# Docker environment variables
|
||||
: "${BIOS:=""}" # BIOS file
|
||||
: "${BIOS:=""}" # BIOS file
|
||||
: "${SECURE:="off"}" # Secure boot
|
||||
|
||||
SECURE="off"
|
||||
BOOT_OPTS=""
|
||||
BOOT_DESC=""
|
||||
|
||||
if [ -n "$BIOS" ]; then
|
||||
BOOT_MODE="custom"
|
||||
BOOT_OPTS="-bios $BIOS"
|
||||
BOOT_DESC=" with custom BIOS file"
|
||||
return 0
|
||||
fi
|
||||
BOOT_OPTS=""
|
||||
[ -n "$BIOS" ] && BOOT_MODE="custom"
|
||||
|
||||
case "${BOOT_MODE,,}" in
|
||||
"legacy" )
|
||||
BOOT_DESC=" with SeaBIOS"
|
||||
;;
|
||||
"uefi" | "" )
|
||||
BOOT_MODE="uefi"
|
||||
ROM="AAVMF_CODE.no-secboot.fd"
|
||||
|
@ -42,6 +33,13 @@ case "${BOOT_MODE,,}" in
|
|||
VARS="AAVMF_VARS.ms.fd"
|
||||
BOOT_OPTS="-rtc base=localtime"
|
||||
;;
|
||||
"legacy" )
|
||||
BOOT_DESC=" with SeaBIOS"
|
||||
;;
|
||||
"custom" )
|
||||
BOOT_OPTS="-bios $BIOS"
|
||||
BOOT_DESC=" with custom BIOS file"
|
||||
;;
|
||||
*)
|
||||
error "Unknown BOOT_MODE, value \"${BOOT_MODE}\" is not recognized!"
|
||||
exit 33
|
||||
|
@ -74,4 +72,29 @@ case "${BOOT_MODE,,}" in
|
|||
;;
|
||||
esac
|
||||
|
||||
MSRS="/sys/module/kvm/parameters/ignore_msrs"
|
||||
if [ -e "$MSRS" ]; then
|
||||
result=$(<"$MSRS")
|
||||
if [[ "$result" == "0" ]] || [[ "${result^^}" == "N" ]]; then
|
||||
echo 1 | tee "$MSRS" > /dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
CLOCKSOURCE="tsc"
|
||||
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
|
||||
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
|
||||
|
||||
if [ ! -f "$CLOCK" ]; then
|
||||
warn "file \"$CLOCK\" cannot not found?"
|
||||
else
|
||||
result=$(<"$CLOCK")
|
||||
case "${result,,}" in
|
||||
"${CLOCKSOURCE,,}" ) ;;
|
||||
"kvm-clock" ) info "Nested KVM virtualization detected.." ;;
|
||||
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected.." ;;
|
||||
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
|
||||
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
|
25
src/proc.sh
25
src/proc.sh
|
@ -24,31 +24,6 @@ if [[ "$CPU" == "Rockchip RK3588"* ]] && [[ "$CORES" == "8" ]]; then
|
|||
[ -z "$CPU_PIN" ] && CPU_PIN="4,5,6,7"
|
||||
fi
|
||||
|
||||
MSRS="/sys/module/kvm/parameters/ignore_msrs"
|
||||
if [ -e "$MSRS" ]; then
|
||||
result=$(<"$MSRS")
|
||||
if [[ "$result" == "0" ]] || [[ "${result^^}" == "N" ]]; then
|
||||
echo 1 | tee "$MSRS" > /dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
CLOCKSOURCE="tsc"
|
||||
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
|
||||
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
|
||||
|
||||
if [ ! -f "$CLOCK" ]; then
|
||||
warn "file \"$CLOCK\" cannot not found?"
|
||||
else
|
||||
result=$(<"$CLOCK")
|
||||
case "${result,,}" in
|
||||
"${CLOCKSOURCE,,}" ) ;;
|
||||
"kvm-clock" ) info "Nested KVM virtualization detected.." ;;
|
||||
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected.." ;;
|
||||
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
|
||||
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ "${ARCH,,}" != "arm64" ]]; then
|
||||
KVM="N"
|
||||
warn "your CPU architecture is ${ARCH^^} and cannot provide KVM acceleration for ARM64 instructions, this will cause a major loss of performance."
|
||||
|
|
|
@ -148,7 +148,7 @@ SPACE_GB=$(formatBytes "$SPACE" "down")
|
|||
AVAIL_MEM=$(formatBytes "$RAM_AVAIL" "down")
|
||||
TOTAL_MEM=$(formatBytes "$RAM_TOTAL" "up")
|
||||
|
||||
echo "❯ CPU: ${CPU} | RAM: ${AVAIL_MEM%% *}/$TOTAL_MEM | DISK: $SPACE_GB (${FS}) | KERNEL: ${SYS}..."
|
||||
echo "❯ CPU: ${CPU} | RAM: ${AVAIL_MEM/ GB/}/$TOTAL_MEM | DISK: $SPACE_GB (${FS}) | KERNEL: ${SYS}..."
|
||||
echo
|
||||
|
||||
# Check compatibilty
|
||||
|
|
Loading…
Reference in a new issue