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