From nobody Fri Nov 14 18:05:12 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1761054686; cv=none; d=zohomail.com; s=zohoarc; b=QdCmi0Jve8VrqQVQVhT9p562c0CzaPFFt8S2kuUIGQ60rY61DvtnVCkPZEwriXnKQ8gQ41Hkt5Yms5EVHbbrA0ufcjzhgmzJBub2YJMODdapsSXGj/PTo0n4VCkBCz+jwPdut0E0J/4C9AXv5XtdSMCC8GR5xCD/5wqB7e9oz/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761054686; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yz9ZkpUNAwEB9OjZoCbrPegu+3lYt5AKKmCiXg5eIJ4=; b=PiFU0mAY3Pr/fnTKeqdh1WHLEVmgVj8z6qXr5kH5FGgHJ90kQLh0yjNYvr0G15rZYIut/s+SWoH42mgq1Shl/mwprHUYBXTFJc04MXzoBw70gROBrFe/XALcTiv2N3eQDeoITUlM+MpGn7f33niI25uZEhbTL4d1dzpVKKiqags= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761054685871306.374178730346; Tue, 21 Oct 2025 06:51:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBCjb-0002F7-J0; Tue, 21 Oct 2025 09:49:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBCjZ-0002ET-GC; Tue, 21 Oct 2025 09:49:05 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBCjW-0006qz-NK; Tue, 21 Oct 2025 09:49:05 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L5OxCE015516; Tue, 21 Oct 2025 13:49:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v326q9w9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 13:49:00 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 59LDmxMu018377; Tue, 21 Oct 2025 13:48:59 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v326q9w5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 13:48:59 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 59LAtb7A014663; Tue, 21 Oct 2025 13:48:58 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 49vn7s376p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 13:48:58 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59LDmsb022414030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Oct 2025 13:48:55 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6F432004E; Tue, 21 Oct 2025 13:48:54 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B62FC2004D; Tue, 21 Oct 2025 13:48:51 +0000 (GMT) Received: from li-3c92a0cc-27cf-11b2-a85c-b804d9ca68fa.ibm.com.com (unknown [9.124.222.96]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Oct 2025 13:48:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=yz9ZkpUNAwEB9OjZo CbrPegu+3lYt5AKKmCiXg5eIJ4=; b=QFK60+Qt/6kejTSAOSabwIUfSLeE0Br16 1RpZKwxlm2PvY1mi45MHc75XOjpSCi7TAuvZh55lx3DzneqMV19lX1gOR8e3YKol T2JAfcY71qsHqLZ7XLA2p0NN90R/8tTAL8QLrz17j3sXpu64n2hkyYBDUZZYggzp tU1YOKNSTQ3Dn+VQx6NfR91/B34gvKNRxk5eyJEYSvipABaufgDSmO/qgVbZAQxi 2wTw9MozccdEVhqwQQ+QkG/qa2QK6BMlzPw6iEukcvf1zeY8Uz1L8sMCm/zbhFfn aic/6U2RM7aCjSAwppq2cl2D6kxQ8EAZH4lu7yIJM2+qUiBmRGOuw== From: Aditya Gupta To: Cc: , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Sourabh Jain , Mahesh J Salgaonkar , Hari Bathini , Chinmay Rath , Thomas Huth , Shivang Upadhyay , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 7/8] tests/functional: Add test for fadump in PSeries Date: Tue, 21 Oct 2025 19:18:17 +0530 Message-ID: <20251021134823.1861675-8-adityag@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021134823.1861675-1-adityag@linux.ibm.com> References: <20251021134823.1861675-1-adityag@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=EJELElZC c=1 sm=1 tr=0 ts=68f78f4c cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=NEAV23lmAAAA:8 a=vTr9H3xdAAAA:8 a=VnNF1IyMAAAA:8 a=Gr56plS7bk8yA4v_bscA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyMiBTYWx0ZWRfXw3rrUNB8nLvr niVwK5JQjyruMFcG1QxgeAYi4juuaBvKNCzcsS8a+9UcUkzanA1zxYESe7Yl/GBevQrLDj92UWg EgBow4rI+KtAspMiSXOZwZJ7YUy2XWDm914mff6XQJeEUSZtH4aLEWou0HoWmRBvOmxvOgLZJ9g g+tj0QtnJnSMOcI8XVswPZXzYBKbtpLENmciUDYS44YCWhvNs7gXvq5H0EJQSEsic+hGTwkoykc FdZDujYD4WxLm66nSAHpLg5dfhjxTYK11Bn4QhOI3Hk06OcRrQdjjIIluICFRphdI8s44/8VIVd NHrJRdFdtZUWw+Qcb/8Mk0MTQnYv2KJTQhhikJq5pjmy3wJ+3B4+hS7hHhORMWbkECmJ8zj8L0R zo1zAcki5Y9HE4963RnU67dJ98IanA== X-Proofpoint-GUID: lvn__1TFMZ0dHAypB6zzXa3iE2Z-9Z8k X-Proofpoint-ORIG-GUID: pD9ab2BeggR1hvwJpZebc0FKNj9uh0DK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_02,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180022 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=adityag@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1761054688681158500 Content-Type: text/plain; charset="utf-8" Add testcases for testing fadump with PSeries and PSeries+KVM combinations It tests if fadump is successfully detected and registered in the first kernel boot. Then crashes the kernel, and verifies whether we have a /proc/vmcore in the 2nd boot Also introduce 'wait_for_regex_console_pattern' to check for cases where there is a single success message, but can have multiple failure messages. This is particularly useful for cases such as fadump, where the success message is "Reserved 1024MB ... successfully" But at the same point, it can fail with multiple errors such as "Not supported" or "Allocation failed" 'wait_for_regex_console_pattern' also has a timeout, for cases when we know the success/failure should appear in a short amount of time, instead of waiting for the much longer test timeout, such as kernels with support of fadump will print the success/failure in earlyboot of the kernel, while kernel without support of fadump won't print anything for long time, and without a timeout the testcase keeps waiting till longer test timeout Signed-off-by: Aditya Gupta --- PowerNV also can be tested with this, will enable PowerNV tests after MPIPL patches go in --- --- tests/functional/ppc64/meson.build | 2 + tests/functional/ppc64/test_fadump.py | 182 ++++++++++++++++++++++ tests/functional/qemu_test/linuxkernel.py | 59 +++++++ 3 files changed, 243 insertions(+) create mode 100755 tests/functional/ppc64/test_fadump.py diff --git a/tests/functional/ppc64/meson.build b/tests/functional/ppc64/me= son.build index 1fa0a70f7ed8..f0f8ab8f6172 100644 --- a/tests/functional/ppc64/meson.build +++ b/tests/functional/ppc64/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later =20 test_ppc64_timeouts =3D { + 'fadump' : 480, 'hv' : 1000, 'mac99' : 120, 'powernv' : 480, @@ -16,6 +17,7 @@ tests_ppc64_system_quick =3D [ =20 tests_ppc64_system_thorough =3D [ 'e500', + 'fadump', 'hv', 'mac99', 'powernv', diff --git a/tests/functional/ppc64/test_fadump.py b/tests/functional/ppc64= /test_fadump.py new file mode 100755 index 000000000000..2d6b8017e8f0 --- /dev/null +++ b/tests/functional/ppc64/test_fadump.py @@ -0,0 +1,182 @@ +#!/usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from unittest import skip +from qemu_test import Asset +from qemu_test import wait_for_console_pattern +from qemu_test import LinuxKernelTest +from qemu_test import exec_command, exec_command_and_wait_for_pattern + +class QEMUFadump(LinuxKernelTest): + """ + Functional test to verify Fadump is working in following scenarios: + + 1. test_fadump_pseries: PSeries + 2. test_fadump_pseries_kvm: PSeries + KVM + """ + + timeout =3D 90 + KERNEL_COMMON_COMMAND_LINE =3D 'console=3Dhvc0 fadump=3Don ' + msg_panic =3D 'Kernel panic - not syncing' + msg_not_supported =3D 'Firmware-Assisted Dump is not supported on this= hardware' + msg_registered_success =3D '' + msg_registered_failed =3D '' + msg_dump_active =3D '' + + ASSET_EPAPR_KERNEL =3D Asset( + ('https://github.com/open-power/op-build/releases/download/v2.7/' + 'zImage.epapr'), + '0ab237df661727e5392cee97460e8674057a883c5f74381a128fa772588d45cd') + + ASSET_VMLINUZ_KERNEL =3D Asset( + ('https://archives.fedoraproject.org/pub/archive/fedora-secondary/' + 'releases/39/Everything/ppc64le/os/ppc/ppc64/vmlinuz'), + ('81e5541d243b50c8f9568906c6918dda22239744d637bb9a7b22d23c3d661226' + '8d5302beb2ca5c06f93bdbc9736c414ef5120756c8bf496ff488ad07d116d67f= ') + ) + + ASSET_FEDORA_INITRD =3D Asset( + ('https://archives.fedoraproject.org/pub/archive/fedora-secondary/' + 'releases/39/Everything/ppc64le/os/ppc/ppc64/initrd.img'), + 'e7f24b44cb2aaa67d30e551db6ac8d29cc57c934b158dabca6b7f885f2cfdd9b') + + def do_test_fadump(self, is_kvm=3DFalse, is_powernv=3DFalse): + """ + Helper Function for Fadump tests below + + It boots the VM with fadump enabled, checks if fadump is correctly + registered. + Then crashes the system causing a QEMU_SYSTEM_RESET, after which + dump should be available in the kernel. + Finally it checks the filesize of the exported /proc/vmcore in 2nd + kernel to verify it's same as the VM's memory size + """ + if is_kvm: + self.require_accelerator("kvm") + self.vm.add_args("-accel", "kvm") + else: + self.require_accelerator("tcg") + + if is_powernv: + self.set_machine("powernv10") + else: + # SLOF takes upto >20s in startup time, use VOF + self.set_machine("pseries") + self.vm.add_args("-machine", "x-vof=3Don") + self.vm.add_args("-m", "6G") + + self.vm.set_console() + + kernel_path =3D None + + if is_powernv: + kernel_path =3D self.ASSET_EPAPR_KERNEL.fetch() + else: + kernel_path =3D self.ASSET_VMLINUZ_KERNEL.fetch() + + initrd_path =3D self.ASSET_FEDORA_INITRD.fetch() + + self.vm.add_args('-kernel', kernel_path) + self.vm.add_args('-initrd', initrd_path) + self.vm.add_args('-append', "fadump=3Don"\ + " -nodefaults -serial mon:stdio crashkernel=3D2G"\ + " rdinit=3D/bin/sh ") + + self.vm.launch() + + # If kernel detects fadump support, and "fadump=3Don" is in command + # line which we add above, it will print something like: + # + # fadump: Reserved 1024MB of memory at 0x00000040000000 ... + # + # Else, if the kernel doesn't detect fadump support, it prints: + # + # fadump: Firmware-Assisted Dump is not supported on this hard= ware + # + # Timeout after 20s if kernel doesn't print any fadump logs, this + # can happen due to fadump being disabled in the kernel + self.wait_for_regex_console_pattern( + success_pattern=3D"fadump: Reserved ", + failure_pattern=3Dr"fadump: (Firmware-Assisted Dump is not"\ + " supported on this hardware|Failed to find memory chunk for"\ + " reservation!)", + timeout=3D20 + ) + + # Ensure fadump is registered successfully, if registration + # succeeds, we get a log from rtas fadump: + # + # rtas fadump: Registration is successful! + self.wait_for_console_pattern( + "rtas fadump: Registration is successful!" + ) + + # Wait for the shell + self.wait_for_console_pattern("#") + + # Mount /proc since not available in the initrd used + exec_command(self, command=3D"mount -t proc proc /proc") + + # Crash the kernel + exec_command(self, command=3D"echo c > /proc/sysrq-trigger") + + # Check for the kernel panic message, setting timeout to 20s as it + # should occur almost immediately after previous echo c + self.wait_for_regex_console_pattern( + success_pattern=3D"Kernel panic - not syncing: sysrq" \ + " triggered crash", + timeout=3D20 + ) + + # Check if fadump is active + # If the kernel shows that fadump is active, that implies it's a + # crashkernel boot + # Else if the kernel shows "fadump: Reserved ..." then it's + # treating this as the first kernel boot, this is likely the case + # that qemu didn't pass the 'ibm,kernel-dump' device tree node + wait_for_console_pattern( + test=3Dself, + success_message=3D"rtas fadump: Firmware-assisted dump is acti= ve", + failure_message=3D"fadump: Reserved " + ) + + # In a successful fadump boot, we get these logs: + # + # [ 0.000000] fadump: Firmware-assisted dump is active. + # [ 0.000000] fadump: Reserving <>MB of memory at <> for preser= ving crash data + # + # Check if these logs are present in the fadump boot + self.wait_for_console_pattern("preserving crash data") + + # Wait for prompt + self.wait_for_console_pattern("sh-5.2#") + + # Mount /proc since not available in the initrd used + exec_command_and_wait_for_pattern(self, + command=3D"mount -t proc proc /proc", + success_message=3D"#" + ) + + # Check if vmcore exists + exec_command_and_wait_for_pattern(self, + command=3D"stat /proc/vmcore", + success_message=3D"File: /proc/vmcore", + failure_message=3D"No such file or directory" + ) + + def test_fadump_pseries(self): + return self.do_test_fadump(is_kvm=3DFalse, is_powernv=3DFalse) + + @skip("PowerNV Fadump not supported yet") + def test_fadump_powernv(self): + return + + def test_fadump_pseries_kvm(self): + """ + Test Fadump in PSeries with KVM accel + """ + self.do_test_fadump(is_kvm=3DTrue, is_powernv=3DFalse) + +if __name__ =3D=3D '__main__': + QEMUFadump.main() diff --git a/tests/functional/qemu_test/linuxkernel.py b/tests/functional/q= emu_test/linuxkernel.py index 2aca0ee3cd03..c4767527daf6 100644 --- a/tests/functional/qemu_test/linuxkernel.py +++ b/tests/functional/qemu_test/linuxkernel.py @@ -5,6 +5,9 @@ =20 import hashlib import urllib.request +import logging +import re +import time =20 from .cmd import wait_for_console_pattern, exec_command_and_wait_for_patte= rn from .testcase import QemuSystemTest @@ -19,6 +22,62 @@ def wait_for_console_pattern(self, success_message, vm= =3DNone): failure_message=3D'Kernel panic - not syn= cing', vm=3Dvm) =20 + def wait_for_regex_console_pattern(self, success_pattern, + failure_pattern=3DNone, + timeout=3DNone): + """ + Similar to 'wait_for_console_pattern', but supports regex patterns, + hence multiple failure/success patterns can be detected at a time. + + Args: + success_pattern (str | re.Pattern): A regex pattern that indic= ates + a successful event. If found, the method exits normally. + failure_pattern (str | re.Pattern, optional): A regex pattern = that + indicates a failure event. If found, the test fails + timeout (int, optional): The maximum time (in seconds) to wait= for + a match. + If exceeded, the test fails. + """ + + console =3D self.vm.console_file + console_logger =3D logging.getLogger('console') + + self.log.debug( + f"Console interaction: success_msg=3D'{success_pattern}' " + + f"failure_msg=3D'{failure_pattern}' timeout=3D'{timeout}s'") + + # Only consume console output if waiting for something + if success_pattern is None and failure_pattern is None: + return + + start_time =3D time.time() + + while time.time() - start_time < timeout: + try: + msg =3D console.readline().decode().strip() + except UnicodeDecodeError: + msg =3D None + if not msg: + continue + console_logger.debug(msg) + if success_pattern is None or re.search(success_pattern, msg): + break + if failure_pattern: + # Find the matching error to print in log + match =3D re.search(failure_pattern, msg) + if not match: + continue + + console.close() + fail =3D 'Failure message found in console: "%s".' \ + ' Expected: "%s"' % \ + (match.group(), success_pattern) + self.fail(fail) + + if time.time() - start_time >=3D timeout: + fail =3D f"Timeout ({timeout}s) while trying to search pattern" + self.fail(fail) + def launch_kernel(self, kernel, initrd=3DNone, dtb=3DNone, console_ind= ex=3D0, wait_for=3DNone): self.vm.set_console(console_index=3Dconsole_index) --=20 2.51.0