1*13336606SRobert Foley#!/usr/bin/env python3 2*13336606SRobert Foley# 3*13336606SRobert Foley# Ubuntu aarch64 image 4*13336606SRobert Foley# 5*13336606SRobert Foley# Copyright 2020 Linaro 6*13336606SRobert Foley# 7*13336606SRobert Foley# Authors: 8*13336606SRobert Foley# Robert Foley <robert.foley@linaro.org> 9*13336606SRobert Foley# Originally based on ubuntu.i386 Fam Zheng <famz@redhat.com> 10*13336606SRobert Foley# 11*13336606SRobert Foley# This code is licensed under the GPL version 2 or later. See 12*13336606SRobert Foley# the COPYING file in the top-level directory. 13*13336606SRobert Foley# 14*13336606SRobert Foley 15*13336606SRobert Foleyimport sys 16*13336606SRobert Foleyimport basevm 17*13336606SRobert Foleyimport aarch64vm 18*13336606SRobert Foleyimport ubuntuvm 19*13336606SRobert Foley 20*13336606SRobert FoleyDEFAULT_CONFIG = { 21*13336606SRobert Foley 'cpu' : "cortex-a57", 22*13336606SRobert Foley 'machine' : "virt,gic-version=3", 23*13336606SRobert Foley 'install_cmds' : "apt-get update,"\ 24*13336606SRobert Foley "apt-get build-dep -y --arch-only qemu,"\ 25*13336606SRobert Foley "apt-get install -y libfdt-dev pkg-config language-pack-en", 26*13336606SRobert Foley # We increase beyond the default time since during boot 27*13336606SRobert Foley # it can take some time (many seconds) to log into the VM 28*13336606SRobert Foley # especially using softmmu. 29*13336606SRobert Foley 'ssh_timeout' : 60, 30*13336606SRobert Foley} 31*13336606SRobert Foley 32*13336606SRobert Foleyclass UbuntuAarch64VM(ubuntuvm.UbuntuVM): 33*13336606SRobert Foley name = "ubuntu.aarch64" 34*13336606SRobert Foley arch = "aarch64" 35*13336606SRobert Foley image_name = "ubuntu-18.04-server-cloudimg-arm64.img" 36*13336606SRobert Foley image_link = "https://cloud-images.ubuntu.com/releases/18.04/release/" + image_name 37*13336606SRobert Foley image_sha256="0fdcba761965735a8a903d8b88df8e47f156f48715c00508e4315c506d7d3cb1" 38*13336606SRobert Foley BUILD_SCRIPT = """ 39*13336606SRobert Foley set -e; 40*13336606SRobert Foley cd $(mktemp -d); 41*13336606SRobert Foley sudo chmod a+r /dev/vdb; 42*13336606SRobert Foley tar --checkpoint=.10 -xf /dev/vdb; 43*13336606SRobert Foley ./configure {configure_opts}; 44*13336606SRobert Foley make --output-sync {target} -j{jobs} {verbose}; 45*13336606SRobert Foley """ 46*13336606SRobert Foley def boot(self, img, extra_args=None): 47*13336606SRobert Foley aarch64vm.create_flash_images(self._tmpdir, self._efi_aarch64) 48*13336606SRobert Foley default_args = aarch64vm.get_pflash_args(self._tmpdir) 49*13336606SRobert Foley if extra_args: 50*13336606SRobert Foley extra_args.extend(default_args) 51*13336606SRobert Foley else: 52*13336606SRobert Foley extra_args = default_args 53*13336606SRobert Foley # We always add these performance tweaks 54*13336606SRobert Foley # because without them, we boot so slowly that we 55*13336606SRobert Foley # can time out finding the boot efi device. 56*13336606SRobert Foley if '-smp' not in extra_args and \ 57*13336606SRobert Foley '-smp' not in self._config['extra_args'] and \ 58*13336606SRobert Foley '-smp' not in self._args: 59*13336606SRobert Foley # Only add if not already there to give caller option to change it. 60*13336606SRobert Foley extra_args.extend(["-smp", "8"]) 61*13336606SRobert Foley 62*13336606SRobert Foley # We have overridden boot() since aarch64 has additional parameters. 63*13336606SRobert Foley # Call down to the base class method. 64*13336606SRobert Foley super(UbuntuAarch64VM, self).boot(img, extra_args=extra_args) 65*13336606SRobert Foley 66*13336606SRobert Foleyif __name__ == "__main__": 67*13336606SRobert Foley defaults = aarch64vm.get_config_defaults(UbuntuAarch64VM, DEFAULT_CONFIG) 68*13336606SRobert Foley sys.exit(basevm.main(UbuntuAarch64VM, defaults)) 69