mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
feat: Display RAM amount warning (#717)
This commit is contained in:
parent
6724ddbd7d
commit
c4a0035062
@ -12,4 +12,18 @@ DEV_OPTS="$DEV_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0
|
||||
ARGS="$DEF_OPTS $CPU_OPTS $RAM_OPTS $MAC_OPTS $DISPLAY_OPTS $MON_OPTS $SERIAL_OPTS $NET_OPTS $DISK_OPTS $DEV_OPTS $ARGUMENTS"
|
||||
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')
|
||||
|
||||
# Check available memory as the very last step
|
||||
|
||||
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
||||
AVAIL_GB=$(( (RAM_AVAIL + 1073741823)/1073741824 ))
|
||||
|
||||
if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then
|
||||
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value."
|
||||
exit 17
|
||||
fi
|
||||
|
||||
if (( (RAM_WANTED + 1450000000) > RAM_AVAIL )); then
|
||||
warn "your configured RAM_SIZE of $WANTED_GB GB is much too close to the $AVAIL_GB GB of memory available, please set a lower value."
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
10
src/reset.sh
10
src/reset.sh
@ -86,13 +86,9 @@ echo
|
||||
|
||||
# Check memory
|
||||
|
||||
if (( RAM_WANTED > RAM_AVAIL )); then
|
||||
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available."
|
||||
exit 15
|
||||
fi
|
||||
|
||||
if (( (RAM_WANTED + 1950000000) > RAM_AVAIL )); then
|
||||
warn "your configured RAM_SIZE of $WANTED_GB GB is much too close to the $AVAIL_GB GB of memory available."
|
||||
if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then
|
||||
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value."
|
||||
exit 17
|
||||
fi
|
||||
|
||||
# Cleanup files
|
||||
|
Loading…
x
Reference in New Issue
Block a user