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