xref: /openbmc/qemu/tests/vm/ubuntu.aarch64 (revision 345d7053)
113336606SRobert Foley#!/usr/bin/env python3
213336606SRobert Foley#
313336606SRobert Foley# Ubuntu aarch64 image
413336606SRobert Foley#
513336606SRobert Foley# Copyright 2020 Linaro
613336606SRobert Foley#
713336606SRobert Foley# Authors:
813336606SRobert Foley#  Robert Foley <robert.foley@linaro.org>
913336606SRobert Foley#  Originally based on ubuntu.i386 Fam Zheng <famz@redhat.com>
1013336606SRobert Foley#
1113336606SRobert Foley# This code is licensed under the GPL version 2 or later.  See
1213336606SRobert Foley# the COPYING file in the top-level directory.
1313336606SRobert Foley#
1413336606SRobert Foley
1513336606SRobert Foleyimport sys
1613336606SRobert Foleyimport basevm
1713336606SRobert Foleyimport aarch64vm
1813336606SRobert Foleyimport ubuntuvm
1913336606SRobert Foley
2013336606SRobert FoleyDEFAULT_CONFIG = {
2113336606SRobert Foley    'cpu'          : "cortex-a57",
2213336606SRobert Foley    'machine'      : "virt,gic-version=3",
2313336606SRobert Foley    'install_cmds' : "apt-get update,"\
2413336606SRobert Foley                     "apt-get build-dep -y --arch-only qemu,"\
25*345d7053SPaolo Bonzini                     "apt-get install -y libfdt-dev pkg-config language-pack-en ninja-build",
2613336606SRobert Foley    # We increase beyond the default time since during boot
2713336606SRobert Foley    # it can take some time (many seconds) to log into the VM
2813336606SRobert Foley    # especially using softmmu.
2913336606SRobert Foley    'ssh_timeout'  : 60,
3013336606SRobert Foley}
3113336606SRobert Foley
3213336606SRobert Foleyclass UbuntuAarch64VM(ubuntuvm.UbuntuVM):
3313336606SRobert Foley    name = "ubuntu.aarch64"
3413336606SRobert Foley    arch = "aarch64"
3513336606SRobert Foley    image_name = "ubuntu-18.04-server-cloudimg-arm64.img"
3613336606SRobert Foley    image_link = "https://cloud-images.ubuntu.com/releases/18.04/release/" + image_name
3713336606SRobert Foley    image_sha256="0fdcba761965735a8a903d8b88df8e47f156f48715c00508e4315c506d7d3cb1"
3813336606SRobert Foley    BUILD_SCRIPT = """
3913336606SRobert Foley        set -e;
4013336606SRobert Foley        cd $(mktemp -d);
4113336606SRobert Foley        sudo chmod a+r /dev/vdb;
4213336606SRobert Foley        tar --checkpoint=.10 -xf /dev/vdb;
4313336606SRobert Foley        ./configure {configure_opts};
4413336606SRobert Foley        make --output-sync {target} -j{jobs} {verbose};
4513336606SRobert Foley    """
4613336606SRobert Foley    def boot(self, img, extra_args=None):
4713336606SRobert Foley        aarch64vm.create_flash_images(self._tmpdir, self._efi_aarch64)
4813336606SRobert Foley        default_args = aarch64vm.get_pflash_args(self._tmpdir)
4913336606SRobert Foley        if extra_args:
5013336606SRobert Foley            extra_args.extend(default_args)
5113336606SRobert Foley        else:
5213336606SRobert Foley            extra_args = default_args
5313336606SRobert Foley        # We always add these performance tweaks
5413336606SRobert Foley        # because without them, we boot so slowly that we
5513336606SRobert Foley        # can time out finding the boot efi device.
5613336606SRobert Foley        if '-smp' not in extra_args and \
5713336606SRobert Foley           '-smp' not in self._config['extra_args'] and \
5813336606SRobert Foley           '-smp' not in self._args:
5913336606SRobert Foley            # Only add if not already there to give caller option to change it.
6013336606SRobert Foley            extra_args.extend(["-smp", "8"])
6113336606SRobert Foley
6213336606SRobert Foley        # We have overridden boot() since aarch64 has additional parameters.
6313336606SRobert Foley        # Call down to the base class method.
6413336606SRobert Foley        super(UbuntuAarch64VM, self).boot(img, extra_args=extra_args)
6513336606SRobert Foley
6613336606SRobert Foleyif __name__ == "__main__":
6713336606SRobert Foley    defaults = aarch64vm.get_config_defaults(UbuntuAarch64VM, DEFAULT_CONFIG)
6813336606SRobert Foley    sys.exit(basevm.main(UbuntuAarch64VM, defaults))
69