selftests/bpf: Allow appending to guest kernel cmdline in vmtest.sh

vmtest.sh currently hardcodes the guest command line, so there is no
way to ask for such a setting without editing the script. Append
$KERNEL_CMDLINE_EXTRA when set so it can be used for testing the
BPF keyring:

   # KERNEL_CMDLINE_EXTRA="bpf.keyring_unsealed=1" \
	./vmtest.sh -- ./test_progs -t signed_loader

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20260828175227.1537793-10-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Daniel Borkmann 2026-08-28 19:52:25 +02:00 committed by Alexei Starovoitov
parent 478cf384de
commit b638a82d64

View File

@ -107,6 +107,14 @@ Options:
-s) Instead of powering off the VM, start an interactive
shell. If <command> is specified, the shell runs after
the command finishes executing
Environment variables:
KERNEL_CMDLINE_EXTRA
Extra arguments to append to the guest kernel command
line, for tests that need a boot-time setting. e.g:
KERNEL_CMDLINE_EXTRA="bpf.keyring_unsealed=1" $0 -- ./test_progs -t signed_loader
EOF
}
@ -286,6 +294,12 @@ EOF
QEMU_FLAGS=("${HOST_FLAGS[@]}")
fi
local kernel_cmdline="root=/dev/vda rw console=${QEMU_CONSOLE}"
if [[ -n "${KERNEL_CMDLINE_EXTRA:-}" ]]; then
kernel_cmdline+=" ${KERNEL_CMDLINE_EXTRA}"
fi
${QEMU_BINARY} \
-nodefaults \
-display none \
@ -294,7 +308,7 @@ EOF
-m 4G \
-drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \
-kernel "${kernel_bzimage}" \
-append "root=/dev/vda rw console=${QEMU_CONSOLE}"
-append "${kernel_cmdline}"
}
copy_logs()