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