feat: Verify required RAM per Windows version (#2085)

This commit is contained in:
Kroese
2026-08-07 03:41:14 +02:00
committed by GitHub
parent 65fe8ada74
commit 43d0478f7e
4 changed files with 21 additions and 50 deletions
+2 -2
View File
@@ -10,7 +10,8 @@ cd /run
. start.sh # Startup hook
. utils.sh # Load functions
. reset.sh # Initialize system
. init.sh # Initialize system
. memory.sh # Check memory
. server.sh # Start webserver
. define.sh # Define versions
. mido.sh # Download Windows
@@ -25,7 +26,6 @@ cd /run
. boot.sh # Configure boot
. proc.sh # Initialize processor
. power.sh # Configure shutdown
. memory.sh # Check available memory
. balloon.sh # Initialize ballooning
. config.sh # Configure arguments
. finish.sh # Finish initialization
+3 -35
View File
@@ -1316,45 +1316,13 @@ backupPrevious () {
checkMemory() {
local id="$1"
local desc="${2:-}"
local required wanted available
local required name
required=$(getRequiredMemory "$id") || return 1
if [ -z "$desc" ]; then
desc=$(printVariant "$id" "$id") || return 1
fi
# Ensure the final memory allocation also uses this floor.
RAM_MINIMUM="$required"
# Refresh host and container memory availability.
getMemoryInfo
available=$(( RAM_AVAIL - RAM_SPARE ))
(( available < 0 )) && available=0
case "${RAM_SIZE,,}" in
"max" )
wanted="$available" ;;
"half" )
wanted=$(( RAM_TOTAL / 2 ))
(( wanted > available )) && wanted="$available" ;;
* )
wanted=$(numfmt --from=iec "$RAM_SIZE") || return 1
if (( wanted < required )); then
error "$desc requires at least $(formatBytes "$required") of RAM, but RAM_SIZE is set to $(formatBytes "$wanted")."
return 1
fi
(( wanted > available )) && wanted="$available" ;;
esac
if (( wanted < required )); then
error "$desc requires at least $(formatBytes "$required") of RAM, but only $(formatBytes "$wanted") can be allocated."
return 1
fi
name=$(printVersion "$id" "") || return 1
checkMemoryRequirement "$name"
return 0
}
+15 -9
View File
@@ -530,15 +530,21 @@ gracefulShutdown() {
finish "$code"
}
enabled "$SHUTDOWN" || return 0
enableTrap() {
enabled "$SHUTDOWN" || return 0
# Keep Ctrl-C available to interactive users without installing an unnecessary
# SIGINT handler for background/container execution.
if interactive; then
_trap gracefulShutdown SIGINT
fi
_trap gracefulShutdown SIGTERM SIGHUP SIGABRT SIGQUIT
return 0
}
[ -n "${QEMU_TIMEOUT:-}" ] && TIMEOUT="$QEMU_TIMEOUT"
# Keep Ctrl-C available to interactive users without installing an unnecessary
# SIGINT handler for background/container execution.
if interactive; then
_trap gracefulShutdown SIGINT
fi
_trap gracefulShutdown SIGTERM SIGHUP SIGABRT SIGQUIT
return 0