From: George Guo <dongtai.guo@linux.dev>
To: Huacai Chen <chenhuacai@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Pratyush Yadav <pratyush@kernel.org>,
Shuah Khan <shuah@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>, Alexander Graf <graf@amazon.com>,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
kexec@lists.infradead.org, linux-mm@kvack.org,
linux-kselftest@vger.kernel.org,
George Guo <guodongtai@kylinos.cn>
Subject: [PATCH v2 4/4] selftests/kho: handle QEMU not exiting after kexec on LoongArch
Date: Fri, 29 May 2026 22:32:38 +0800 [thread overview]
Message-ID: <20260529143238.169169-5-dongtai.guo@linux.dev> (raw)
In-Reply-To: <20260529143238.169169-1-dongtai.guo@linux.dev>
From: George Guo <guodongtai@kylinos.cn>
On LoongArch, QEMU provides only a minimal EFI stub with no runtime
services and no ACPI tables, so machine_restart() falls through to
its infinite idle loop and QEMU never exits after kexec. The test
result is already printed to the serial console and vmtest.sh reports
success, but the user must press Ctrl+C to get the prompt back.
Add QEMU_NEEDS_KILL=1 to loongarch.conf so the test completes
unattended.
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
tools/testing/selftests/kho/loongarch.conf | 3 ++
tools/testing/selftests/kho/vmtest.sh | 32 ++++++++++++++++++----
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kho/loongarch.conf b/tools/testing/selftests/kho/loongarch.conf
index 0145cb49e5b2..02a6add633f1 100644
--- a/tools/testing/selftests/kho/loongarch.conf
+++ b/tools/testing/selftests/kho/loongarch.conf
@@ -8,3 +8,6 @@ CONFIG_SERIAL_8250_CONSOLE=y
"
KERNEL_IMAGE="vmlinux.efi"
KERNEL_CMDLINE="console=ttyS0 earlycon"
+# QEMU never exits after kexec on LoongArch (no EFI runtime services),
+# so vmtest.sh must kill it once the test verdict appears.
+QEMU_NEEDS_KILL=1
diff --git a/tools/testing/selftests/kho/vmtest.sh b/tools/testing/selftests/kho/vmtest.sh
index a6ae9ac09595..821e13fa69a5 100755
--- a/tools/testing/selftests/kho/vmtest.sh
+++ b/tools/testing/selftests/kho/vmtest.sh
@@ -107,12 +107,32 @@ function run_qemu() {
cmdline="$cmdline kho=on panic=-1"
- $qemu_cmd -m 1G -smp 2 -no-reboot -nographic -nodefaults \
- -accel kvm -accel hvf -accel tcg \
- -serial file:"$serial" \
- -append "$cmdline" \
- -kernel "$kernel" \
- -initrd "$initrd"
+ local qemu_args=(
+ -m 1G -smp 2 -no-reboot -nographic -nodefaults
+ -accel kvm -accel hvf -accel tcg
+ -serial file:"$serial"
+ -append "$cmdline"
+ -kernel "$kernel"
+ -initrd "$initrd"
+ )
+
+ # If the target does not exit QEMU after kexec (e.g. no EFI runtime
+ # services), the conf file sets QEMU_NEEDS_KILL=1. Run QEMU in the
+ # background, poll for the test verdict, then kill it.
+ if [[ "${QEMU_NEEDS_KILL:-0}" == "1" ]]; then
+ $qemu_cmd "${qemu_args[@]}" &
+ local qemu_pid=$!
+ local remaining=100
+ while ((remaining-- > 0)); do
+ grep -q "KHO restore succeeded\|KHO restore failed" \
+ "$serial" 2>/dev/null && break
+ sleep 1
+ done
+ kill "$qemu_pid" 2>/dev/null
+ wait "$qemu_pid" 2>/dev/null || true
+ else
+ $qemu_cmd "${qemu_args[@]}"
+ fi
grep "KHO restore succeeded" "$serial" &> /dev/null || fail "KHO failed"
}
--
2.25.1
next prev parent reply other threads:[~2026-05-29 14:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 14:32 George Guo
2026-05-29 14:32 ` [PATCH v2 1/4] LoongArch: kexec: add KHO support for FDT-based systems George Guo
2026-05-29 14:32 ` [PATCH v2 2/4] LoongArch: kexec: add KHO support for ACPI-only systems George Guo
2026-05-29 14:32 ` [PATCH v2 3/4] selftests/kho: add LoongArch vmtest support George Guo
2026-05-29 14:32 ` George Guo [this message]
2026-05-31 9:28 ` Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260529143238.169169-5-dongtai.guo@linux.dev \
--to=dongtai.guo@linux.dev \
--cc=chenhuacai@kernel.org \
--cc=graf@amazon.com \
--cc=guodongtai@kylinos.cn \
--cc=kernel@xen0n.name \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=loongarch@lists.linux.dev \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
powered by JetHome