xref: /openbmc/qemu/tests/avocado/boot_xen.py (revision b22bf37dffe47993d37f2809cc16b7f4e99c619e)
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
25    timeout = 90
26    XEN_COMMON_COMMAND_LINE = 'dom0_mem=128M loglvl=all guest_loglvl=all'
27
28    def fetch_guest_kernel(self):
29        # Using my own built kernel - which works
30        kernel_url = ('https://fileserver.linaro.org/'
31                      's/JSsewXGZ6mqxPr5/download?path=%2F&files='
32                      'linux-5.9.9-arm64-ajb')
33        kernel_sha1 = '4f92bc4b9f88d5ab792fa7a43a68555d344e1b83'
34        kernel_path = self.fetch_asset(kernel_url,
35                                       asset_hash=kernel_sha1)
36
37        return kernel_path
38
39    def launch_xen(self, xen_path):
40        """
41        Launch Xen with a dom0 guest kernel
42        """
43        self.log.info("launch with xen_path: %s", xen_path)
44        kernel_path = self.fetch_guest_kernel()
45
46        self.vm.set_console()
47
48        xen_command_line = self.XEN_COMMON_COMMAND_LINE
49        self.vm.add_args('-machine', 'virtualization=on',
50                         '-m', '768',
51                         '-kernel', xen_path,
52                         '-append', xen_command_line,
53                         '-device',
54                         'guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0'
55                         % (kernel_path))
56
57        self.vm.launch()
58
59        console_pattern = 'VFS: Cannot open root device'
60        wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
61
62    def test_arm64_xen_411_and_dom0(self):
63        """
64        :avocado: tags=arch:aarch64
65        :avocado: tags=accel:tcg
66        :avocado: tags=cpu:cortex-a57
67        :avocado: tags=machine:virt
68        """
69
70        # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
71        xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
72                   'download?path=%2F&files='
73                   'xen-hypervisor-4.11-arm64_4.11.4%2B37-g3263f257ca-1_arm64.deb')
74        xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'
75        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
76        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64")
77
78        self.launch_xen(xen_path)
79
80    def test_arm64_xen_414_and_dom0(self):
81        """
82        :avocado: tags=arch:aarch64
83        :avocado: tags=accel:tcg
84        :avocado: tags=cpu:cortex-a57
85        :avocado: tags=machine:virt
86        """
87
88        # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
89        xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
90                   'download?path=%2F&files='
91                   'xen-hypervisor-4.14-arm64_4.14.0%2B80-gd101b417b7-1_arm64.deb')
92        xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160'
93        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
94        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.14-arm64")
95
96        self.launch_xen(xen_path)
97
98    def test_arm64_xen_415_and_dom0(self):
99        """
100        :avocado: tags=arch:aarch64
101        :avocado: tags=accel:tcg
102        :avocado: tags=cpu:cortex-a57
103        :avocado: tags=machine:virt
104        """
105
106        xen_url = ('https://fileserver.linaro.org/'
107                   's/JSsewXGZ6mqxPr5/download'
108                   '?path=%2F&files=xen-upstream-4.15-unstable.deb')
109        xen_sha1 = 'fc191172b85cf355abb95d275a24cc0f6d6579d8'
110        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
111        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.15-unstable")
112
113        self.launch_xen(xen_path)
114