Skip to content

Commit

Permalink
feat: Detect nested virtualization (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Oct 12, 2024
1 parent 2fa64cf commit b6be959
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ else
CPU_FLAGS="$DEFAULT_FLAGS,$CPU_FLAGS"
fi

CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
[ -f "$CLOCK" ] && CLOCK=$(<"$CLOCK")

if [[ "${CLOCK,,}" == "kvm-clock" ]]; then
if [[ "$CPU_VENDOR" != "GenuineIntel" ]] && [[ "${CPU_CORES,,}" == "2" ]]; then
warn "Restricted processor to a single core because nested virtualization was detected!"
CPU_CORES="1"
else
warn "Nested virtualization was detected, this might cause issues running macOS!"
fi
fi

if [[ "${CLOCK,,}" == "hpet" ]]; then
warn "Your clocksource is HPET instead of TSC, this will cause issues running macOS!"
fi

case "$CPU_CORES" in
"" | "0" | "3" ) CPU_CORES="2" ;;
"5" ) CPU_CORES="4" ;;
Expand Down

0 comments on commit b6be959

Please sign in to comment.