Detect insufficient RAM for Windows and macOS Close #78

Also changes the RAM allocation for the VM to better attempt a working configuration.
This commit is contained in:
Martin Wimpress 2021-10-09 16:51:14 +01:00
parent 247b3d8a4e
commit d1afc10857
No known key found for this signature in database
GPG key ID: 61DF940515E06DA3

View file

@ -297,22 +297,27 @@ function vm_boot() {
RAM_HOST=$(free --mega -h | grep Mem | cut -d':' -f2 | cut -d'G' -f1 | sed 's/ //g') RAM_HOST=$(free --mega -h | grep Mem | cut -d':' -f2 | cut -d'G' -f1 | sed 's/ //g')
#Round up - https://github.com/wimpysworld/quickemu/issues/11 #Round up - https://github.com/wimpysworld/quickemu/issues/11
RAM_HOST=$(printf '%.*f\n' 0 "${RAM_HOST}") RAM_HOST=$(printf '%.*f\n' 0 "${RAM_HOST}")
if [ "${RAM_HOST}" -ge 256 ]; then if [ "${RAM_HOST}" -ge 128 ]; then
RAM_VM="32G" RAM_VM="32G"
elif [ "${RAM_HOST}" -ge 128 ]; then
RAM_VM="16G"
elif [ "${RAM_HOST}" -ge 64 ]; then elif [ "${RAM_HOST}" -ge 64 ]; then
RAM_VM="8G" RAM_VM="16G"
elif [ "${RAM_HOST}" -ge 32 ]; then
RAM_VM="4G"
elif [ "${RAM_HOST}" -ge 16 ]; then elif [ "${RAM_HOST}" -ge 16 ]; then
RAM_VM="3G" RAM_VM="8G"
elif [ "${RAM_HOST}" -ge 8 ]; then
RAM_VM="4G"
fi fi
else else
RAM_VM="${ram}" RAM_VM="${ram}"
fi fi
echo ", ${RAM_VM} RAM" echo ", ${RAM_VM} RAM"
if [ ${RAM_VM//G/} -lt 4 ]; then
if [ "${guest_os}" == "macos" ] || [ "${guest_os}" == "windows" ]; then
echo "ERROR! You have insufficient RAM to run ${guest_os} in a VM"
exit 1
fi
fi
# Make any OS specific adjustments # Make any OS specific adjustments
case ${guest_os} in case ${guest_os} in
freebsd|linux) freebsd|linux)