diff --git a/build_image b/build_image index e80ad9d634..d7f09fef37 100755 --- a/build_image +++ b/build_image @@ -100,6 +100,7 @@ fi . "${BUILD_LIBRARY_DIR}/prod_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/dev_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1 +. "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1 PROD_IMAGE=0 DEV_IMAGE=0 @@ -216,7 +217,7 @@ print_image_to_vm() { To convert it to a virtual machine image, use: ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD} ${flags} -The default type is qemu, see ./image_to_vm.sh --help for other options. +The default type is $(get_default_vm_type ${BOARD}), see ./image_to_vm.sh --help for other options. EOF } diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 88b65c5d08..7e927c838e 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -296,6 +296,22 @@ IMG_interoute_BUNDLE_FORMAT=ova ########################################################### +# Print the default vm type for the specified board +get_default_vm_type() { + local board="$1" + case "$board" in + amd64-usr) + echo "qemu" + ;; + arm64-usr) + echo "qemu_uefi" + ;; + *) + return 1 + ;; + esac +} + # Validate and set the vm type to use for the rest of the functions set_vm_type() { local vm_type="$1" diff --git a/image_to_vm.sh b/image_to_vm.sh index 8526606a2d..8f8071f196 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -28,7 +28,7 @@ DEFINE_string board "${DEFAULT_BOARD}" \ # We default to TRUE so the buildbot gets its image. Note this is different # behavior from image_to_usb.sh -DEFINE_string format "qemu" \ +DEFINE_string format "" \ "Output format, one of: ${VALID_IMG_TYPES[*]}" DEFINE_string from "" \ "Directory containing rootfs.image and mbr.image" @@ -59,6 +59,10 @@ switch_to_strict_mode check_gsutil_opts +if [[ -z "${FLAGS_format}" ]]; then + FLAGS_format="$(get_default_vm_type ${FLAGS_board})" +fi + if ! set_vm_type "${FLAGS_format}"; then die_notrace "Invalid format: ${FLAGS_format}" fi