Fix #21 configurable RAM and #22 configurable cores (#24)

* Fix #21 configurable RAM and #22 configurable cores

* Initialize new config values with empty strings
This commit is contained in:
Marcus Grenängen 2020-04-13 00:30:11 +02:00 committed by GitHub
parent 64cff9bbab
commit 8618421abb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -279,23 +279,31 @@ function vm_boot() {
fi fi
local CORES_VM="1" local CORES_VM="1"
local CORES_HOST=$(nproc --all) if [ -z "$cpu_cores" ]; then
if [ ${CORES_HOST} -ge 8 ]; then local CORES_HOST=$(nproc --all)
CORES_VM="4" if [ ${CORES_HOST} -ge 8 ]; then
elif [ ${CORES_HOST} -ge 4 ]; then CORES_VM="4"
CORES_VM="2" elif [ ${CORES_HOST} -ge 4 ]; then
CORES_VM="2"
fi
else
CORES_VM="$cpu_cores"
fi fi
local SMP="-smp ${CORES_VM},sockets=1,cores=${CORES_VM},threads=1" local SMP="-smp ${CORES_VM},sockets=1,cores=${CORES_VM},threads=1"
echo " - CPU: ${CORES_VM} Core(s)" echo " - CPU: ${CORES_VM} Core(s)"
local RAM_VM="2G" local RAM_VM="2G"
local RAM_HOST=$(free --mega -h | grep Mem | cut -d':' -f2 | cut -d'G' -f1 | sed 's/ //g') if [ -z "$ram" ]; then
#Round up - https://github.com/wimpysworld/quickemu/issues/11 local RAM_HOST=$(free --mega -h | grep Mem | cut -d':' -f2 | cut -d'G' -f1 | sed 's/ //g')
RAM_HOST=$(printf '%.*f\n' 0 ${RAM_HOST}) #Round up - https://github.com/wimpysworld/quickemu/issues/11
if [ ${RAM_HOST} -ge 64 ]; then RAM_HOST=$(printf '%.*f\n' 0 ${RAM_HOST})
RAM_VM="4G" if [ ${RAM_HOST} -ge 64 ]; then
elif [ ${RAM_HOST} -ge 16 ]; then RAM_VM="4G"
RAM_VM="3G" elif [ ${RAM_HOST} -ge 16 ]; then
RAM_VM="3G"
fi
else
RAM_VM="$ram"
fi fi
echo " - RAM: ${RAM_VM}" echo " - RAM: ${RAM_VM}"
@ -505,6 +513,8 @@ driver_iso=""
disk_img="" disk_img=""
disk="64G" disk="64G"
usb_devices=() usb_devices=()
ram=""
cpu_cores=""
DELETE=0 DELETE=0
ENABLE_EFI=0 ENABLE_EFI=0