diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 9eb3d2ff14..1f819648a4 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -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 @@ -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##*:}" diff --git a/image_to_vm.sh b/image_to_vm.sh index b9ea8b5f87..444acc2fc8 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -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." @@ -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}" \