Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/vsock: auto-detect kernel for guest VMs

When running vmtest.sh inside a nested VM the running kernel may not be
installed on the filesystem at the standard /boot/ or /usr/lib/modules/
paths.

Previously, this would cause vng to fail with "does not exist" since it
could not find the kernel image. Instead, this patch uses --dry-run to
detect if the kernel is available. If not, then we fall back to the
kernel in the kernel source tree. If that fails, then we die.

This way runners, like NIPA, can use vng --run arch/x86/boot/bzImage to
setup an outer VM, and vmtest.sh will still do the right thing setting
up the inner VM.

Due to job control issues in vng, a workaround is used to prevent 'make
kselftest TARGETS=vsock' from hanging until test timeout. A PR has been
placed upstream to solve the issue in vng:

https://github.com/arighi/virtme-ng/pull/453

Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260316-vsock-vmtest-autodetect-kernel-v2-1-5eec7b4831f8@meta.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Bobby Eshleman and committed by
Jakub Kicinski
3883c2b5 76eea68d

+19
+19
tools/testing/selftests/vsock/vmtest.sh
··· 415 415 done 416 416 } 417 417 418 + vng_dry_run() { 419 + # WORKAROUND: use setsid to work around a virtme-ng bug where vng hangs 420 + # when called from a background process group (e.g., under make 421 + # kselftest). vng save/restores terminal settings using tcsetattr(), 422 + # which is not allowed for background process groups because the 423 + # controlling terminal is owned by the foreground process group. vng is 424 + # stopped with SIGTTOU and hangs until kselftest's timer expires. 425 + # setsid works around this by launching vng in a new session that has 426 + # no controlling terminal, so tcsetattr() succeeds. 427 + 428 + setsid -w vng --run "$@" --dry-run &>/dev/null 429 + } 430 + 418 431 vm_start() { 419 432 local pidfile=$1 420 433 local ns=$2 ··· 454 441 455 442 if [[ "${BUILD}" -eq 1 ]]; then 456 443 kernel_opt="${KERNEL_CHECKOUT}" 444 + elif vng_dry_run; then 445 + kernel_opt="" 446 + elif vng_dry_run "${KERNEL_CHECKOUT}"; then 447 + kernel_opt="${KERNEL_CHECKOUT}" 448 + else 449 + die "No suitable kernel found" 457 450 fi 458 451 459 452 if [[ "${ns}" != "init_ns" ]]; then