xref: /qemu/tests/functional/test_aarch64_xen.py (revision 7698afc42b5af9e55f12ab2236618e38e5a1c23f)
1#!/usr/bin/env python3
2#
3# Functional test that boots a Xen hypervisor with a domU kernel and
4# checks the console output is vaguely sane .
5#
6# Copyright (c) 2020 Linaro
7#
8# Author:
9#  Alex Bennée <alex.bennee@linaro.org>
10#
11# SPDX-License-Identifier: GPL-2.0-or-later
12#
13# This work is licensed under the terms of the GNU GPL, version 2 or
14# later.  See the COPYING file in the top-level directory.
15
16from qemu_test import Asset, LinuxKernelTest, wait_for_console_pattern
17
18
19class BootXen(LinuxKernelTest):
20    """
21    Boots a Xen hypervisor with a Linux DomU kernel.
22    """
23
24    timeout = 90
25    XEN_COMMON_COMMAND_LINE = 'dom0_mem=128M loglvl=all guest_loglvl=all'
26
27    ASSET_KERNEL = Asset(
28        ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
29         'download?path=%2F&files=linux-5.9.9-arm64-ajb'),
30        '00366fa51ea957c19462d2e2aefd480bef80ce727120e714ae48e0c88f261edb')
31
32    def launch_xen(self, xen_path):
33        """
34        Launch Xen with a dom0 guest kernel
35        """
36        self.require_accelerator("tcg") # virtualization=on
37        self.set_machine('virt')
38        self.cpu = "cortex-a57"
39        self.kernel_path = self.ASSET_KERNEL.fetch()
40        self.log.info("launch with xen_path: %s", xen_path)
41
42        self.vm.set_console()
43
44        self.vm.add_args('-machine', 'virtualization=on',
45                         '-m', '768',
46                         '-kernel', xen_path,
47                         '-append', self.XEN_COMMON_COMMAND_LINE,
48                         '-device',
49                         'guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0'
50                         % (self.kernel_path))
51
52        self.vm.launch()
53
54        console_pattern = 'VFS: Cannot open root device'
55        wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
56
57    ASSET_XEN_4_11 = Asset(
58        ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/download?path=%2F&'
59         'files=xen-hypervisor-4.11-arm64_4.11.4%2B37-g3263f257ca-1_arm64.deb'),
60        'b745c2631342f9fcc0147ddc364edb62c20ecfebd430e5a3546e7d7c6891c0bc')
61
62    def test_arm64_xen_411_and_dom0(self):
63        # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
64        xen_path = self.archive_extract(self.ASSET_XEN_4_11, format='deb',
65                                        member="boot/xen-4.11-arm64")
66        self.launch_xen(xen_path)
67
68    ASSET_XEN_4_14 = Asset(
69        ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/download?path=%2F&'
70         'files=xen-hypervisor-4.14-arm64_4.14.0%2B80-gd101b417b7-1_arm64.deb'),
71        'e930a3293248edabd367d5b4b3b6448b9c99c057096ea8b47228a7870661d5cb')
72
73    def test_arm64_xen_414_and_dom0(self):
74        # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
75        xen_path = self.archive_extract(self.ASSET_XEN_4_14, format='deb',
76                                        member="boot/xen-4.14-arm64")
77        self.launch_xen(xen_path)
78
79    ASSET_XEN_4_15 = Asset(
80        ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/download?path=%2F&'
81         'files=xen-upstream-4.15-unstable.deb'),
82        '2a9a8af8acf0231844657cc28baab95bd918b0ee2d493ee4ee6f8846e1358bc9')
83
84    def test_arm64_xen_415_and_dom0(self):
85        xen_path = self.archive_extract(self.ASSET_XEN_4_15, format='deb',
86                                        member="boot/xen-4.15-unstable")
87        self.launch_xen(xen_path)
88
89
90if __name__ == '__main__':
91    LinuxKernelTest.main()
92