xref: /openbmc/qemu/tests/avocado/boot_xen.py (revision 7d87775f)
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 setUp(self):
34        super(BootXen, self).setUp()
35
36        # Using my own built kernel - which works
37        kernel_url = ('https://fileserver.linaro.org/'
38                      's/JSsewXGZ6mqxPr5/download?path=%2F&files='
39                      'linux-5.9.9-arm64-ajb')
40        kernel_sha1 = '4f92bc4b9f88d5ab792fa7a43a68555d344e1b83'
41        self.kernel_path = self.fetch_asset(kernel_url,
42                                            asset_hash=kernel_sha1)
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
50        self.vm.set_console()
51
52        self.vm.add_args('-machine', 'virtualization=on',
53                         '-m', '768',
54                         '-kernel', xen_path,
55                         '-append', self.XEN_COMMON_COMMAND_LINE,
56                         '-device',
57                         'guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0'
58                         % (self.kernel_path))
59
60        self.vm.launch()
61
62        console_pattern = 'VFS: Cannot open root device'
63        wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
64
65    def test_arm64_xen_411_and_dom0(self):
66        # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
67        xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
68                   'download?path=%2F&files='
69                   'xen-hypervisor-4.11-arm64_4.11.4%2B37-g3263f257ca-1_arm64.deb')
70        xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'
71        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
72        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64")
73
74        self.launch_xen(xen_path)
75
76    def test_arm64_xen_414_and_dom0(self):
77        # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
78        xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
79                   'download?path=%2F&files='
80                   'xen-hypervisor-4.14-arm64_4.14.0%2B80-gd101b417b7-1_arm64.deb')
81        xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160'
82        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
83        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.14-arm64")
84
85        self.launch_xen(xen_path)
86
87    def test_arm64_xen_415_and_dom0(self):
88        xen_url = ('https://fileserver.linaro.org/'
89                   's/JSsewXGZ6mqxPr5/download'
90                   '?path=%2F&files=xen-upstream-4.15-unstable.deb')
91        xen_sha1 = 'fc191172b85cf355abb95d275a24cc0f6d6579d8'
92        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
93        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.15-unstable")
94
95        self.launch_xen(xen_path)
96