#!/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 softmmu.
    '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))
