[PATCH 07/13] qemu: track the latest stable upstream release

Daniel Gomez <[email protected]> Fri, 12 Jun 2026 14:36:45 +0200
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
From: Daniel Gomez <[email protected]>

The upstream QEMU_GIT_VERSION default was pinned to v8.0.0-rc1, a stale
release candidate. Default it instead to the latest stable release
inferred from the /mirror/qemu.git mirror by a new
scripts/infer_last_stable_qemu.sh, which lists the vX.Y.Z release tags,
drops release candidates and picks the newest, mirroring the kernel's
infer_last_stable_kernel.sh. When no mirror is present it falls back to
a recent release rather than a release candidate.

The jic23 tree keeps its explicit CXL branch and a manual URL keeps its
free-form version, so only the upstream default changes.

Generated-by: Claude AI
Signed-off-by: Daniel Gomez <[email protected]>
---
 MAINTAINERS                       |  1 +
 docs/qemu.md                      |  7 +++++--
 kconfigs/Kconfig.qemu             | 10 ++++++----
 scripts/infer_last_stable_qemu.sh | 31 +++++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index bbfa01aa..85392004 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -192,6 +192,7 @@ F:	docs/qemu.md
 F:	kconfigs/Kconfig.qemu
 F:	playbooks/qemu.yml
 F:	playbooks/roles/qemu/
+F:	scripts/infer_last_stable_qemu.sh
 F:	scripts/qemu.Makefile
 
 QEMU SYSTEM UNITS (QSU)
diff --git a/docs/qemu.md b/docs/qemu.md
index 3db3a3ec..ce4899ce 100644
--- a/docs/qemu.md
+++ b/docs/qemu.md
@@ -35,8 +35,11 @@ directory `qemu-build/` and the install destdir `qemu-destdir/`.
 
 ## Version (`QEMU_GIT_VERSION`)
 
-The git ref (tag or branch) to check out and build. Use at least v7.2.0 for CXL
-support.
+The git ref (tag or branch) to check out and build. For the upstream tree this
+defaults to the latest stable release, inferred from the `/mirror/qemu.git`
+mirror by `scripts/infer_last_stable_qemu.sh`; when no mirror is present it
+falls back to a recent release. Override it to pin a specific tag, and use at
+least v7.2.0 for CXL support.
 
 ## Build target (`QEMU_TARGET`)
 
diff --git a/kconfigs/Kconfig.qemu b/kconfigs/Kconfig.qemu
index 549b322b..1b61630b 100644
--- a/kconfigs/Kconfig.qemu
+++ b/kconfigs/Kconfig.qemu
@@ -69,11 +69,13 @@ config QEMU_GIT_VERSION
 	string "The version of QEMU to build"
 	output yaml
 	default "cxl-2023-05-19" if QEMU_JIC23
-	default "v8.0.0-rc1" if QEMU_UPSTREAM
+	default $(shell, scripts/infer_last_stable_qemu.sh) if QEMU_UPSTREAM
 	help
-	  This is the target build version of QEMU to build. Please use
-	  at least v7.2.0 for CXL support. v8.0.0-rc1 has some build fixes
-	  for newer compilers so it is the default now.
+	  This is the target build version of QEMU to build. For the upstream
+	  tree this defaults to the latest stable release inferred from the
+	  /mirror/qemu.git mirror by scripts/infer_last_stable_qemu.sh, with a
+	  recent release as the fallback when no mirror is present. Override it
+	  to pin a specific tag or branch.
 
 config QEMU_USE_DEVELOPMENT_VERSION
 	bool
diff --git a/scripts/infer_last_stable_qemu.sh b/scripts/infer_last_stable_qemu.sh
new file mode 100755
index 00000000..aab85e47
--- /dev/null
+++ b/scripts/infer_last_stable_qemu.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+# SPDX-License-Identifier: copyleft-next-0.3.1
+
+# This script infers the last stable QEMU version from a local git mirror.
+# It looks for the most recent vX.Y.Z release tag (excluding -rc tags) and
+# echoes it, so the upstream QEMU build tracks the latest release instead of
+# a stale pinned version. Mirrors scripts/infer_last_stable_kernel.sh.
+
+GIT_TREE="${1:-/mirror/qemu.git}"
+
+# Fallback used when no mirror is available (for example on a fresh checkout
+# or in CI). Kept as a real, recent release rather than a release candidate.
+FALLBACK="v10.0.0"
+
+if [ ! -d "$GIT_TREE" ]; then
+    echo "$FALLBACK"
+    exit 0
+fi
+
+# List proper vX.Y.Z release tags, drop release candidates, sort by version
+# and take the newest.
+LAST_STABLE=$(git --git-dir="$GIT_TREE" tag --list 'v*' | \
+    grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \
+    sort -V | \
+    tail -1)
+
+if [ -z "$LAST_STABLE" ]; then
+    echo "$FALLBACK"
+else
+    echo "$LAST_STABLE"
+fi

-- 
2.54.0