feat(quickemu): allow overriding insufficient RAM error

When RAM is not specified in the config and the min RAM is not met, quickemu tells the user to override the RAM amount and exits.
If the user overrides the RAM, the script should allow the user to continue with a warning.
This commit is contained in:
takase1121 2024-06-25 16:23:35 +08:00 committed by Martin Wimpress
parent 4b30ea21f4
commit 3a07d353b9
1 changed files with 17 additions and 9 deletions

View File

@ -579,17 +579,25 @@ function configure_ram() {
fi fi
echo " - RAM VM: ${RAM_VM} RAM" echo " - RAM VM: ${RAM_VM} RAM"
if [ "${guest_os}" == "windows" ] || [ "${guest_os}" == "windows-server" ]; then case "${guest_os}" in
if [ "${RAM_VM//G/}" -lt 4 ]; then windows|windows-server)
echo "ERROR! The guest virtual machine has been allocated insufficient RAM to run Windows." os_pretty_name="Windows"
min_ram="4"
;;
macos)
os_pretty_name="macOS"
min_ram="8"
;;
esac
if [ -n "${min_ram}" ] && [ "${RAM_VM//G/}" -lt "${min_ram}" ]; then
if [ -z "${ram}" ]; then
echo "ERROR! The guest virtual machine has been allocated insufficient RAM to run ${os_pretty_name}."
echo " You can override the guest RAM allocation by adding 'ram=4G' to ${VM}" echo " You can override the guest RAM allocation by adding 'ram=4G' to ${VM}"
exit 1 exit 1
fi else
elif [ "${guest_os}" == "macos" ]; then echo "WARNING! The guest virtual machine has been allocated less than the recommended RAM to run ${os_pretty_name}."
if [ "${RAM_VM//G/}" -lt 8 ]; then echo " You have been warned."
echo "ERROR! The guest virtual machine has been allocated insufficient RAM to run macOS."
echo " You can override the guest RAM allocation by adding 'ram=8G' to ${VM}"
exit 1
fi fi
fi fi
} }