feat: CPU flags (#586)

This commit is contained in:
Kroese 2024-01-21 20:52:53 +01:00 committed by GitHub
parent 1e13258bc9
commit 0c74201eb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 7 deletions

View File

@ -3,8 +3,8 @@ set -Eeuo pipefail
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}"
CPU_OPTS="-cpu $CPU_FLAGS -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1"
MAC_OPTS="-machine type=q35,usb=off,vmport=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
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"

View File

@ -5,8 +5,8 @@ set -Eeuo pipefail
: "${KVM:="Y"}"
: "${HOST_CPU:=""}"
: "${CPU_FLAGS:=""}"
: "${CPU_MODEL:="host"}"
: "${CPU_FEATURES:="+ssse3,+sse4.1,+sse4.2"}"
[ "$ARCH" != "amd64" ] && KVM="N"
@ -37,6 +37,7 @@ fi
if [[ "$KVM" != [Nn]* ]]; then
CPU_FEATURES="kvm=on"
KVM_OPTS=",accel=kvm -enable-kvm"
if ! grep -qE '^flags.* (sse4_2)' /proc/cpuinfo; then
@ -48,15 +49,23 @@ if [[ "$KVM" != [Nn]* ]]; then
else
KVM_OPTS=""
CPU_FEATURES="+ssse3,+sse4.1,+sse4.2"
if [[ "${CPU_MODEL,,}" == "host"* ]]; then
if [[ "$CPU_MODEL" == "host"* ]]; then
if [[ "$ARCH" == "amd64" ]]; then
CPU_MODEL="max,$CPU_FEATURES"
CPU_MODEL="max"
else
CPU_MODEL="qemu64,$CPU_FEATURES"
CPU_MODEL="qemu64"
fi
fi
fi
if [ -z "$CPU_FLAGS" ]; then
CPU_FLAGS="$CPU_MODEL,$CPU_FEATURES"
else
CPU_FLAGS="$CPU_MODEL,$CPU_FEATURES,$CPU_FLAGS"
fi
if [ -z "$HOST_CPU" ]; then