| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Test that Linux kernel boots on ppc machines and check the console |
| 4 | # |
| 5 | # Copyright (c) 2018, 2020 Red Hat, Inc. |
| 6 | # |
| 7 | # This work is licensed under the terms of the GNU GPL, version 2 or |
| 8 | # later. See the COPYING file in the top-level directory. |
| 9 | |
| 10 | from qemu_test import Asset |
| 11 | from qemu_test import wait_for_console_pattern |
| 12 | from migration import MigrationTest |
| 13 | |
| 14 | class PseriesMachine(MigrationTest): |
| 15 | |
| 16 | timeout = 90 |
| 17 | KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 ' |
| 18 | panic_message = 'Kernel panic - not syncing' |
| 19 | good_message = 'VFS: Cannot open root device' |
| 20 | |
| 21 | ASSET_KERNEL = Asset( |
| 22 | ('https://archives.fedoraproject.org/pub/archive/fedora-secondary/' |
| 23 | 'releases/29/Everything/ppc64le/os/ppc/ppc64/vmlinuz'), |
| 24 | '383c2f5c23bc0d9d32680c3924d3fd7ee25cc5ef97091ac1aa5e1d853422fc5f') |
| 25 | |
| 26 | def do_test_ppc64_linux_boot(self, kernel_command_line = KERNEL_COMMON_COMMAND_LINE): |
| 27 | kernel_path = self.ASSET_KERNEL.fetch() |
| 28 | |
| 29 | self.vm.set_console() |
| 30 | self.vm.add_args('-kernel', kernel_path, |
| 31 | '-append', kernel_command_line) |
| 32 | self.vm.launch() |
| 33 | |
| 34 | def test_ppc64_vof_linux_boot(self): |
| 35 | self.set_machine('pseries') |
| 36 | self.vm.add_args('-machine', 'x-vof=on') |
| 37 | self.do_test_ppc64_linux_boot() |
| 38 | console_pattern = 'VFS: Cannot open root device' |
| 39 | wait_for_console_pattern(self, console_pattern, self.panic_message) |
| 40 | |
| 41 | def test_ppc64_linux_boot(self): |
| 42 | self.set_machine('pseries') |
| 43 | self.do_test_ppc64_linux_boot() |
| 44 | console_pattern = 'VFS: Cannot open root device' |
| 45 | wait_for_console_pattern(self, console_pattern, self.panic_message) |
| 46 | |
| 47 | def test_ppc64_linux_smp_boot(self): |
| 48 | self.set_machine('pseries') |
| 49 | self.vm.add_args('-smp', '4') |
| 50 | self.do_test_ppc64_linux_boot() |
| 51 | console_pattern = 'smp: Brought up 1 node, 4 CPUs' |
| 52 | wait_for_console_pattern(self, console_pattern, self.panic_message) |
| 53 | wait_for_console_pattern(self, self.good_message, self.panic_message) |
| 54 | |
| 55 | def test_ppc64_linux_hpt_smp_boot(self): |
| 56 | self.set_machine('pseries') |
| 57 | self.vm.add_args('-smp', '4') |
| 58 | self.do_test_ppc64_linux_boot(self.KERNEL_COMMON_COMMAND_LINE + |
| 59 | 'disable_radix') |
| 60 | console_pattern = 'smp: Brought up 1 node, 4 CPUs' |
| 61 | wait_for_console_pattern(self, 'hash-mmu: Initializing hash mmu', |
| 62 | self.panic_message) |
| 63 | wait_for_console_pattern(self, console_pattern, self.panic_message) |
| 64 | wait_for_console_pattern(self, self.good_message, self.panic_message) |
| 65 | |
| 66 | def test_ppc64_linux_smt_boot(self): |
| 67 | self.set_machine('pseries') |
| 68 | self.vm.add_args('-smp', '4,threads=4') |
| 69 | self.do_test_ppc64_linux_boot() |
| 70 | console_pattern = 'CPU maps initialized for 4 threads per core' |
| 71 | wait_for_console_pattern(self, console_pattern, self.panic_message) |
| 72 | console_pattern = 'smp: Brought up 1 node, 4 CPUs' |
| 73 | wait_for_console_pattern(self, console_pattern, self.panic_message) |
| 74 | wait_for_console_pattern(self, self.good_message, self.panic_message) |
| 75 | |
| 76 | def test_ppc64_linux_big_boot(self): |
| 77 | self.set_machine('pseries') |
| 78 | self.vm.add_args('-smp', '16,threads=4,cores=2,sockets=2') |
| 79 | self.vm.add_args('-m', '512M', |
| 80 | '-object', 'memory-backend-ram,size=256M,id=m0', |
| 81 | '-object', 'memory-backend-ram,size=256M,id=m1') |
| 82 | self.vm.add_args('-numa', 'node,nodeid=0,memdev=m0') |
| 83 | self.vm.add_args('-numa', 'node,nodeid=1,memdev=m1') |
| 84 | self.do_test_ppc64_linux_boot() |
| 85 | console_pattern = 'CPU maps initialized for 4 threads per core' |
| 86 | wait_for_console_pattern(self, console_pattern, self.panic_message) |
| 87 | console_pattern = 'smp: Brought up 2 nodes, 16 CPUs' |
| 88 | wait_for_console_pattern(self, console_pattern, self.panic_message) |
| 89 | wait_for_console_pattern(self, self.good_message, self.panic_message) |
| 90 | |
| 91 | def test_ppc64_linux_migration(self): |
| 92 | self.set_machine('pseries') |
| 93 | |
| 94 | kernel_path = self.ASSET_KERNEL.fetch() |
| 95 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE |
| 96 | |
| 97 | dest_vm = self.get_vm(name="dest-qemu") |
| 98 | dest_vm.add_args('-incoming', 'defer') |
| 99 | dest_vm.add_args('-smp', '4') |
| 100 | dest_vm.add_args('-nodefaults') |
| 101 | dest_vm.add_args('-kernel', kernel_path, |
| 102 | '-append', kernel_command_line) |
| 103 | dest_vm.set_console() |
| 104 | dest_vm.launch() |
| 105 | |
| 106 | source_vm = self.get_vm(name="source-qemu") |
| 107 | source_vm.add_args('-smp', '4') |
| 108 | source_vm.add_args('-nodefaults') |
| 109 | source_vm.add_args('-kernel', kernel_path, |
| 110 | '-append', kernel_command_line) |
| 111 | source_vm.set_console() |
| 112 | source_vm.launch() |
| 113 | |
| 114 | # ensure the boot has reached Linux |
| 115 | console_pattern = 'smp: Brought up 1 node, 4 CPUs' |
| 116 | wait_for_console_pattern(self, console_pattern, self.panic_message, |
| 117 | vm=source_vm) |
| 118 | |
| 119 | self.migration_with_tcp_localhost_vms(dest_vm, source_vm) |
| 120 | |
| 121 | # ensure the boot proceeds after migration |
| 122 | wait_for_console_pattern(self, self.good_message, self.panic_message, |
| 123 | vm=dest_vm) |
| 124 | |
| 125 | if __name__ == '__main__': |
| 126 | MigrationTest.main() |