xref: /openbmc/qemu/tests/avocado/boot_xen.py (revision 1b88da0a)
1# Functional test that boots a Xen hypervisor with a domU kernel and
2# checks the console output is vaguely sane .
3#
4# Copyright (c) 2020 Linaro
5#
6# Author:
7#  Alex Bennée <alex.bennee@linaro.org>
8#
9# SPDX-License-Identifier: GPL-2.0-or-later
10#
11# This work is licensed under the terms of the GNU GPL, version 2 or
12# later.  See the COPYING file in the top-level directory.
13
14import os
15
16from avocado_qemu import wait_for_console_pattern
17from boot_linux_console import LinuxKernelTest
18
19
20class BootXen(LinuxKernelTest):
21    """
22    Boots a Xen hypervisor with a Linux DomU kernel.
23
24    :avocado: tags=arch:aarch64
25    :avocado: tags=accel:tcg
26    :avocado: tags=cpu:cortex-a57
27    :avocado: tags=machine:virt
28    """
29
30    timeout = 90
31    XEN_COMMON_COMMAND_LINE = 'dom0_mem=128M loglvl=all guest_loglvl=all'
32
33    def fetch_guest_kernel(self):
34        # Using my own built kernel - which works
35        kernel_url = ('https://fileserver.linaro.org/'
36                      's/JSsewXGZ6mqxPr5/download?path=%2F&files='
37                      'linux-5.9.9-arm64-ajb')
38        kernel_sha1 = '4f92bc4b9f88d5ab792fa7a43a68555d344e1b83'
39        kernel_path = self.fetch_asset(kernel_url,
40                                       asset_hash=kernel_sha1)
41
42        return kernel_path
43
44    def launch_xen(self, xen_path):
45        """
46        Launch Xen with a dom0 guest kernel
47        """
48        self.log.info("launch with xen_path: %s", xen_path)
49        kernel_path = self.fetch_guest_kernel()
50
51        self.vm.set_console()
52
53        self.vm.add_args('-machine', 'virtualization=on',
54                         '-m', '768',
55                         '-kernel', xen_path,
56                         '-append', self.XEN_COMMON_COMMAND_LINE,
57                         '-device',
58                         'guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0'
59                         % (kernel_path))
60
61        self.vm.launch()
62
63        console_pattern = 'VFS: Cannot open root device'
64        wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
65
66    def test_arm64_xen_411_and_dom0(self):
67        # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
68        xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
69                   'download?path=%2F&files='
70                   'xen-hypervisor-4.11-arm64_4.11.4%2B37-g3263f257ca-1_arm64.deb')
71        xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'
72        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
73        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64")
74
75        self.launch_xen(xen_path)
76
77    def test_arm64_xen_414_and_dom0(self):
78        # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
79        xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
80                   'download?path=%2F&files='
81                   'xen-hypervisor-4.14-arm64_4.14.0%2B80-gd101b417b7-1_arm64.deb')
82        xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160'
83        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
84        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.14-arm64")
85
86        self.launch_xen(xen_path)
87
88    def test_arm64_xen_415_and_dom0(self):
89        xen_url = ('https://fileserver.linaro.org/'
90                   's/JSsewXGZ6mqxPr5/download'
91                   '?path=%2F&files=xen-upstream-4.15-unstable.deb')
92        xen_sha1 = 'fc191172b85cf355abb95d275a24cc0f6d6579d8'
93        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
94        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.15-unstable")
95
96        self.launch_xen(xen_path)
97