From: Albert Esteve <aesteve@redhat.com>
To: "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Shuah Khan" <shuah@kernel.org>
Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Albert Esteve <aesteve@redhat.com>,
mripard@redhat.com, Eric Chanudet <echanude@redhat.com>
Subject: [PATCH v2 4/4] selftests: cgroup: handle vmtest-dmem -b to test locally built kernel
Date: Tue, 21 Apr 2026 09:19:50 +0200 [thread overview]
Message-ID: <20260421-kunit_cgroups-v2-4-bb6675d8249c@redhat.com> (raw)
In-Reply-To: <20260421-kunit_cgroups-v2-0-bb6675d8249c@redhat.com>
From: Eric Chanudet <echanude@redhat.com>
Currently vmtest-dmem.sh relies on the host's running kernel or a
pre-built one when booting the virtme-ng VM, with no option to
configure and build a local kernel tree directly.
This adds friction to the development cycle: the user must manually
run vng --kconfig with the correct config fragment, build the kernel,
and pass the result to the script.
Add a -b flag that automates this workflow. When set, handle_build()
configures the kernel using vng --kconfig with the selftest config
fragment, builds it with make -j$(nproc), and vm_start() passes the
local tree to vng --run so the VM boots the freshly built kernel.
Signed-off-by: Eric Chanudet <echanude@redhat.com>
Signed-off-by: Albert Esteve <aesteve@redhat.com>
---
tools/testing/selftests/cgroup/vmtest-dmem.sh | 34 ++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cgroup/vmtest-dmem.sh b/tools/testing/selftests/cgroup/vmtest-dmem.sh
index 3174f22b06361..a5f1e529e1aa0 100755
--- a/tools/testing/selftests/cgroup/vmtest-dmem.sh
+++ b/tools/testing/selftests/cgroup/vmtest-dmem.sh
@@ -23,6 +23,7 @@ readonly WAIT_TOTAL=$((WAIT_PERIOD * WAIT_PERIOD_MAX))
readonly QEMU_PIDFILE="$(mktemp /tmp/qemu_dmem_vmtest_XXXX.pid)"
readonly QEMU_OPTS=" --pidfile ${QEMU_PIDFILE} "
+BUILD=0
QEMU="qemu-system-$(uname -m)"
VERBOSE=0
SHELL_MODE=0
@@ -72,17 +73,46 @@ check_deps() {
done
}
+handle_build() {
+ if [[ ! "${BUILD}" -eq 1 ]]; then
+ return
+ fi
+
+ if [[ ! -d "${KERNEL_CHECKOUT}" ]]; then
+ echo "-b requires vmtest.sh called from the kernel source tree" >&2
+ exit 1
+ fi
+
+ pushd "${KERNEL_CHECKOUT}" &>/dev/null
+
+ if ! vng --kconfig --config "${SCRIPT_DIR}"/config; then
+ die "failed to generate .config for kernel source tree (${KERNEL_CHECKOUT})"
+ fi
+
+ if ! make -j"$(nproc)"; then
+ die "failed to build kernel from source tree (${KERNEL_CHECKOUT})"
+ fi
+
+ popd &>/dev/null
+}
+
vm_start() {
local logfile=/dev/null
local verbose_opt=""
+ local kernel_opt=""
if [[ "${VERBOSE}" -eq 2 ]]; then
verbose_opt="--verbose"
logfile=/dev/stdout
fi
+ if [[ "${BUILD}" -eq 1 ]]; then
+ kernel_opt="${KERNEL_CHECKOUT}"
+ fi
+
vng \
--run \
+ "$kernel_opt" \
${verbose_opt} \
--qemu-opts="${QEMU_OPTS}" \
--qemu="$(command -v "${QEMU}")" \
@@ -165,10 +195,11 @@ run_test() {
vm_ssh -- "cd '${GUEST_TREE}' && ./tools/testing/selftests/cgroup/test_dmem"
}
-while getopts ":hvq:s" o; do
+while getopts ":hvq:sb" o; do
case "${o}" in
v) VERBOSE=$((VERBOSE + 1)) ;;
q) QEMU="${OPTARG}" ;;
+ b) BUILD=1 ;;
s) SHELL_MODE=1 ;;
h|*) usage ;;
esac
@@ -177,6 +208,7 @@ done
trap cleanup EXIT
check_deps
+handle_build
echo "Booting virtme-ng VM..."
vm_start
vm_wait_for_ssh
--
2.52.0
prev parent reply other threads:[~2026-04-21 7:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 7:19 [PATCH v2 0/4] cgroup: dmem: add selftest helper, coverage, and VM runner Albert Esteve
2026-04-21 7:19 ` [PATCH v2 1/4] cgroup: Add dmem_selftest module Albert Esteve
2026-04-21 7:19 ` [PATCH v2 2/4] selftests: cgroup: Add dmem selftest coverage Albert Esteve
2026-04-21 7:19 ` [PATCH v2 3/4] selftests: cgroup: Add vmtest-dmem runner based on hid vmtest Albert Esteve
2026-04-21 7:19 ` Albert Esteve [this message]
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=20260421-kunit_cgroups-v2-4-bb6675d8249c@redhat.com \
--to=aesteve@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=echanude@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=mripard@redhat.com \
--cc=shuah@kernel.org \
--cc=tj@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