Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
build_library: Add function get_vm_mem
Browse files Browse the repository at this point in the history
ARM64 builds tend to run out of memory with only 1024 MiB, so
replace the IMG_DEFAULT_MEM constant with a new function
get_vm_mem that returns a default memory size based
the board.

Signed-off-by: Geoff Levand <[email protected]>
  • Loading branch information
glevand committed Apr 17, 2018
1 parent 21880b1 commit bfe4b41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 13 additions & 3 deletions build_library/vm_image_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ IMG_DEFAULT_CONF_FORMAT=
# Bundle configs and disk image into some archive
IMG_DEFAULT_BUNDLE_FORMAT=

# Memory size to use in any config files
IMG_DEFAULT_MEM=1024

# Number of CPUs to use in any config files
IMG_DEFAULT_CPUS=2

Expand Down Expand Up @@ -331,6 +328,19 @@ set_vm_type() {
return 1
}

# Print memory size to use in any config files
get_vm_mem() {
local board="$1"
local vm_mem="$(_get_vm_opt MEM)"
if [[ -z ${vm_mem} ]]; then
case "$board" in
arm64-usr) vm_mem="2048";;
*) vm_mem="1024";;
esac
fi
echo "${vm_mem}"
}

# Validate and set the oem package, colon delimited USE optional
set_vm_oem_pkg() {
local oem_pkg="${1%:*}" oem_use="${1##*:}"
Expand Down
6 changes: 5 additions & 1 deletion image_to_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DEFINE_string from "" \
"Directory containing coreos_developer_image.bin or coreos_production_image.bin."
DEFINE_string disk_layout "" \
"The disk layout type to use for this image."
DEFINE_integer mem "${DEFAULT_MEM}" \
DEFINE_integer mem "" \
"Memory size for the vm config in MBs."
DEFINE_boolean dev_image "${FLAGS_FALSE}" \
"Use the development image instead of the default production image."
Expand Down Expand Up @@ -75,6 +75,10 @@ if [ -z "${FLAGS_board}" ] ; then
die_notrace "--board is required."
fi

if [[ -z "${FLAGS_mem}" ]]; then
FLAGS_mem=$(get_vm_mem ${FLAGS_board})
fi

# If downloading packages is enabled ensure the board is configured properly.
if [[ ${FLAGS_getbinpkg} -eq ${FLAGS_TRUE} ]]; then
"${SRC_ROOT}/scripts/setup_board" --board="${FLAGS_board}" \
Expand Down

0 comments on commit bfe4b41

Please sign in to comment.