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
|
set -Eeuo pipefail
|
||||||
|
|
||||||
# Docker environment variables
|
# Docker environment variables
|
||||||
: "${BIOS:=""}" # BIOS file
|
: "${BIOS:=""}" # BIOS file
|
||||||
|
: "${SECURE:="off"}" # Secure boot
|
||||||
|
|
||||||
SECURE="off"
|
|
||||||
BOOT_OPTS=""
|
|
||||||
BOOT_DESC=""
|
BOOT_DESC=""
|
||||||
|
BOOT_OPTS=""
|
||||||
if [ -n "$BIOS" ]; then
|
[ -n "$BIOS" ] && BOOT_MODE="custom"
|
||||||
BOOT_MODE="custom"
|
|
||||||
BOOT_OPTS="-bios $BIOS"
|
|
||||||
BOOT_DESC=" with custom BIOS file"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "${BOOT_MODE,,}" in
|
case "${BOOT_MODE,,}" in
|
||||||
"legacy" )
|
|
||||||
BOOT_DESC=" with SeaBIOS"
|
|
||||||
;;
|
|
||||||
"uefi" | "" )
|
"uefi" | "" )
|
||||||
BOOT_MODE="uefi"
|
BOOT_MODE="uefi"
|
||||||
ROM="AAVMF_CODE.no-secboot.fd"
|
ROM="AAVMF_CODE.no-secboot.fd"
|
||||||
|
@ -42,6 +33,13 @@ case "${BOOT_MODE,,}" in
|
||||||
VARS="AAVMF_VARS.ms.fd"
|
VARS="AAVMF_VARS.ms.fd"
|
||||||
BOOT_OPTS="-rtc base=localtime"
|
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!"
|
error "Unknown BOOT_MODE, value \"${BOOT_MODE}\" is not recognized!"
|
||||||
exit 33
|
exit 33
|
||||||
|
@ -74,4 +72,29 @@ case "${BOOT_MODE,,}" in
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
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"
|
[ -z "$CPU_PIN" ] && CPU_PIN="4,5,6,7"
|
||||||
fi
|
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
|
if [[ "${ARCH,,}" != "arm64" ]]; then
|
||||||
KVM="N"
|
KVM="N"
|
||||||
warn "your CPU architecture is ${ARCH^^} and cannot provide KVM acceleration for ARM64 instructions, this will cause a major loss of performance."
|
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")
|
AVAIL_MEM=$(formatBytes "$RAM_AVAIL" "down")
|
||||||
TOTAL_MEM=$(formatBytes "$RAM_TOTAL" "up")
|
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
|
echo
|
||||||
|
|
||||||
# Check compatibilty
|
# Check compatibilty
|
||||||
|
|
Loading…
Reference in a new issue