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