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