| #!/usr/bin/env python3 | |
| # | |
| # Ubuntu aarch64 image | |
| # | |
| # Copyright 2020 Linaro | |
| # | |
| # Authors: | |
| # Robert Foley <robert.foley@linaro.org> | |
| # Originally based on ubuntu.i386 Fam Zheng <famz@redhat.com> | |
| # | |
| # This code is licensed under the GPL version 2 or later. See | |
| # the COPYING file in the top-level directory. | |
| # | |
| import sys | |
| import basevm | |
| import aarch64vm | |
| import ubuntuvm | |
| DEFAULT_CONFIG = { | |
| 'cpu' : "cortex-a57", | |
| 'machine' : "virt,gic-version=3", | |
| 'install_cmds' : "apt-get update,"\ | |
| "apt-get build-dep -y --arch-only qemu,"\ | |
| "apt-get install -y libfdt-dev pkg-config language-pack-en ninja-build", | |
| # We increase beyond the default time since during boot | |
| # it can take some time (many seconds) to log into the VM | |
| # especially using TCG. | |
| 'ssh_timeout' : 60, | |
| } | |
| class UbuntuAarch64VM(ubuntuvm.UbuntuVM): | |
| name = "ubuntu.aarch64" | |
| arch = "aarch64" | |
| # NOTE: The Ubuntu 20.04 cloud images are periodically updated. The | |
| # fixed image chosen below is the latest release at time of | |
| # writing. Using a rolling latest instead would mean that the SHA | |
| # would be incorrect at an indeterminate point in the future. | |
| image_name = "focal-server-cloudimg-arm64.img" | |
| image_link = "https://cloud-images.ubuntu.com/focal/20220615/" + image_name | |
| image_sha256="95a027336e197debe88c92ff2e554598e23c409139e1e750b71b3b820b514832" | |
| BUILD_SCRIPT = """ | |
| set -e; | |
| cd $(mktemp -d); | |
| sudo chmod a+r /dev/vdb; | |
| tar --checkpoint=.10 -xf /dev/vdb; | |
| ./configure {configure_opts}; | |
| make --output-sync {target} -j{jobs} {verbose}; | |
| """ | |
| def boot(self, img, extra_args=None): | |
| aarch64vm.create_flash_images(self._tmpdir, self._efi_aarch64) | |
| default_args = aarch64vm.get_pflash_args(self._tmpdir) | |
| if extra_args: | |
| extra_args.extend(default_args) | |
| else: | |
| extra_args = default_args | |
| # We always add these performance tweaks | |
| # because without them, we boot so slowly that we | |
| # can time out finding the boot efi device. | |
| if '-smp' not in extra_args and \ | |
| '-smp' not in self._config['extra_args'] and \ | |
| '-smp' not in self._args: | |
| # Only add if not already there to give caller option to change it. | |
| extra_args.extend(["-smp", "8"]) | |
| # We have overridden boot() since aarch64 has additional parameters. | |
| # Call down to the base class method. | |
| super(UbuntuAarch64VM, self).boot(img, extra_args=extra_args) | |
| if __name__ == "__main__": | |
| defaults = aarch64vm.get_config_defaults(UbuntuAarch64VM, DEFAULT_CONFIG) | |
| sys.exit(basevm.main(UbuntuAarch64VM, defaults)) |