f226d6
From 6e304517801fdfb58df582e37cd4df04b5adc1b6 Mon Sep 17 00:00:00 2001
f226d6
From: Frantisek Sumsal <frantisek@sumsal.cz>
f226d6
Date: Fri, 12 Nov 2021 21:43:12 +0100
f226d6
Subject: [PATCH] test: don't use `-cpu max` in GH Actions
f226d6
f226d6
There appears to be an issue with newer QEMU versions (spotted with Arch
f226d6
Linux and C9S containers) which causes the respective GH Action to hang
f226d6
when booting a QEMU VM in combination with the `-cpu max` parameter.
f226d6
f226d6
During (a particularly painful) debugging session I once managed to get
f226d6
some output from such "frozen" machine (using `earlycon` and
f226d6
`earlyprintk` kernel cmdline options), and in that particular case the
f226d6
VM died with a trap caused by an invalid opcode.
f226d6
f226d6
I couldn't reproduce this locally, only in GH Actions environment with
f226d6
Arch Linux and C9S containers. Also, so far I haven't found out which
f226d6
specific CPUID flag causes this, but using the `IvyBridge-v2` feature
f226d6
set seems to mitigate the issue.
f226d6
f226d6
(cherry picked from commit 3f56d481e8a3c67c2e795686e6ec3bfc4ea08e1d)
f226d6
---
f226d6
 test/run-qemu        | 5 +++--
f226d6
 tools/test-github.sh | 1 +
f226d6
 2 files changed, 4 insertions(+), 2 deletions(-)
f226d6
f226d6
diff --git a/test/run-qemu b/test/run-qemu
f226d6
index 3c521a14..5dc61037 100755
f226d6
--- a/test/run-qemu
f226d6
+++ b/test/run-qemu
f226d6
@@ -3,13 +3,14 @@
f226d6
 # We prefer kvm, kqemu, userspace in that order.
f226d6
 
f226d6
 export PATH=/usr/sbin:/usr/bin:/sbin:/bin
f226d6
+QEMU_CPU="${QEMU_CPU:-max}"
f226d6
 
f226d6
-[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS=(-cpu max)
f226d6
+[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS=(-cpu "$QEMU_CPU")
f226d6
 (lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS=(-kernel-kqemu -cpu host)
f226d6
 [[ -c /dev/kvm && -x /usr/bin/kvm ]] && BIN=/usr/bin/kvm && ARGS=(-cpu host)
f226d6
 [[ -c /dev/kvm && -x /usr/bin/qemu-kvm ]] && BIN=/usr/bin/qemu-kvm && ARGS=(-cpu host)
f226d6
 [[ -c /dev/kvm && -x /usr/libexec/qemu-kvm ]] && BIN=/usr/libexec/qemu-kvm && ARGS=(-cpu host)
f226d6
-[[ -x /usr/bin/qemu-system-$(uname -m) ]] && BIN=/usr/bin/qemu-system-$(uname -m) && ARGS=(-cpu max)
f226d6
+[[ -x /usr/bin/qemu-system-$(uname -m) ]] && BIN=/usr/bin/qemu-system-$(uname -m) && ARGS=(-cpu "$QEMU_CPU")
f226d6
 [[ -c /dev/kvm && -x /usr/bin/qemu-system-$(uname -m) ]] && BIN=/usr/bin/qemu-system-$(uname -m) && ARGS=(-enable-kvm -cpu host)
f226d6
 
f226d6
 [[ $BIN ]] || {
f226d6
diff --git a/tools/test-github.sh b/tools/test-github.sh
f226d6
index eab59dcc..1d61b8e3 100755
f226d6
--- a/tools/test-github.sh
f226d6
+++ b/tools/test-github.sh
f226d6
@@ -41,6 +41,7 @@ else
f226d6
             cd /lib/modules
f226d6
             ls -1 | tail -1
f226d6
         )" \
f226d6
+        QEMU_CPU="IvyBridge-v2" \
f226d6
         DRACUT_NO_XATTR=1 \
f226d6
         TEST_RUN_ID="$RUN_ID" \
f226d6
         ${TESTS:+TESTS="$TESTS"} \
f226d6