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: Automaticly adjust CPU core count #47

Merged
merged 4 commits into from
Jun 12, 2024
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN gzip -d /tmp/opencore.iso.gz && \
rm -rf /tmp/*

FROM scratch AS runner
COPY --from=qemux/qemu-docker:5.13 / /
COPY --from=qemux/qemu-docker:5.15 / /

ARG VERSION_ARG="0.0"
ARG VERSION_OPENCORE="1.0.0"
Expand Down
27 changes: 0 additions & 27 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,33 +126,6 @@ kubectl apply -f kubernetes.yml
CPU_CORES: "4"
```

Please be aware that macOS may have issues when the configured CPU core count is not a power of two (2, 4, 8, 16, etc).

* ### How do I add multiple disks?

To create additional disks, modify your compose file like this:

```yaml
environment:
DISK2_SIZE: "32G"
DISK3_SIZE: "64G"
volumes:
- /home/example:/storage2
- /mnt/data/example:/storage3
```

* ### How do I pass-through a disk?

It is possible to pass-through disk devices directly by adding them to your compose file in this way:

```yaml
devices:
- /dev/sdb:/disk1
- /dev/sdc:/disk2
```

Use `/disk1` if you want it to become your main drive, and use `/disk2` and higher to add them as secondary drives.

* ### How do I pass-through a USB device?

To pass-through a USB device, first lookup its vendor and product id via the `lsusb` command, then add them to your compose file like this:
Expand Down
25 changes: 24 additions & 1 deletion src/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ DEFAULT_FLAGS="vendor=GenuineIntel,vmware-cpuid-freq=on,-pdpe1gb"

if [[ "$CPU_VENDOR" != "GenuineIntel" ]] || [[ "${KVM:-}" == [Nn]* ]]; then
[ -z "${CPU_MODEL:-}" ] && CPU_MODEL="Haswell-noTSX"
DEFAULT_FLAGS+=",+pcid,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+xsave,+xsaveopt,+rdrand,check"
DEFAULT_FLAGS+=",+pcid,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+smep,+xsave,+xsavec,+xsaveopt,+xgetbv1,+movbe,+rdrand,check"
fi

if [ -z "${CPU_FLAGS:-}" ]; then
Expand All @@ -98,6 +98,29 @@ else
CPU_FLAGS="$DEFAULT_FLAGS,$CPU_FLAGS"
fi

[ -z "${CPU_CORES:-}" ] && CPU_CORES="2"

if [[ "$CPU_VENDOR" != "GenuineIntel" ]] || [[ "${KVM:-}" == [Nn]* ]]; then
SMP="$CPU_CORES,sockets=$CPU_CORES,dies=1,cores=1,threads=1"
else
case "$CPU_CORES" in
"3" ) CPU_CORES="2" ;;
"5" ) CPU_CORES="4" ;;
"9" ) CPU_CORES="8" ;;
esac
case "$CPU_CORES" in
"1" | "2" | "4" | "8" ) SMP="$CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" ;;
"6" | "7" ) SMP="$CPU_CORES,sockets=3,dies=1,cores=2,threads=1" ;;
"10" | "11" ) SMP="$CPU_CORES,sockets=5,dies=1,cores=2,threads=1" ;;
"12" | "13" ) SMP="$CPU_CORES,sockets=3,dies=1,cores=4,threads=1" ;;
"14" | "15" ) SMP="$CPU_CORES,sockets=7,dies=1,cores=2,threads=1" ;;
"16" | "32" | "64" ) SMP="$CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" ;;
*)
error "Invalid amount of CPU_CORES, value \"${CPU_CORES}\" is not a power of 2!" && exit 35
;;
esac
fi

USB="nec-usb-xhci,id=xhci"
USB+=" -device usb-kbd,bus=xhci.0"
USB+=" -global nec-usb-xhci.msi=off"
Expand Down