Merge remote-tracking branch 'qemu-project/master'
[qemu/ar7.git] / tests / vm / ubuntu.aarch64
blobeeda281f875de896592e66ea63eca902a9d6b982
1 #!/usr/bin/env python3
3 # Ubuntu aarch64 image
5 # Copyright 2020 Linaro
7 # Authors:
8 #  Robert Foley <robert.foley@linaro.org>
9 #  Originally based on ubuntu.i386 Fam Zheng <famz@redhat.com>
11 # This code is licensed under the GPL version 2 or later.  See
12 # the COPYING file in the top-level directory.
15 import sys
16 import basevm
17 import aarch64vm
18 import ubuntuvm
20 DEFAULT_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 TCG.
29     'ssh_timeout'  : 60,
32 class UbuntuAarch64VM(ubuntuvm.UbuntuVM):
33     name = "ubuntu.aarch64"
34     arch = "aarch64"
35     # NOTE: The Ubuntu 20.04 cloud images are periodically updated. The
36     # fixed image chosen below is the latest release at time of
37     # writing. Using a rolling latest instead would mean that the SHA
38     # would be incorrect at an indeterminate point in the future.
39     image_name = "focal-server-cloudimg-arm64.img"
40     image_link = "https://cloud-images.ubuntu.com/focal/20220615/" + image_name
41     image_sha256="95a027336e197debe88c92ff2e554598e23c409139e1e750b71b3b820b514832"
42     BUILD_SCRIPT = """
43         set -e;
44         cd $(mktemp -d);
45         sudo chmod a+r /dev/vdb;
46         tar --checkpoint=.10 -xf /dev/vdb;
47         ./configure {configure_opts};
48         make --output-sync {target} -j{jobs} {verbose};
49     """
50     def boot(self, img, extra_args=None):
51         aarch64vm.create_flash_images(self._tmpdir, self._efi_aarch64)
52         default_args = aarch64vm.get_pflash_args(self._tmpdir)
53         if extra_args:
54             extra_args.extend(default_args)
55         else:
56             extra_args = default_args
57         # We always add these performance tweaks
58         # because without them, we boot so slowly that we
59         # can time out finding the boot efi device.
60         if '-smp' not in extra_args and \
61            '-smp' not in self._config['extra_args'] and \
62            '-smp' not in self._args:
63             # Only add if not already there to give caller option to change it.
64             extra_args.extend(["-smp", "8"])
66         # We have overridden boot() since aarch64 has additional parameters.
67         # Call down to the base class method.
68         super(UbuntuAarch64VM, self).boot(img, extra_args=extra_args)
70 if __name__ == "__main__":
71     defaults = aarch64vm.get_config_defaults(UbuntuAarch64VM, DEFAULT_CONFIG)
72     sys.exit(basevm.main(UbuntuAarch64VM, defaults))