From f2422206c693f40036ed938d54be8b9a2298dc35 Mon Sep 17 00:00:00 2001 From: Gregory Detal Date: Tue, 30 Apr 2024 13:03:43 +0000 Subject: [PATCH] run: allow to pass environment variable to the VM This change uses the .bash_profile file from the home directory that is mounted in the VM to pass/update environment variables: - append the kernel tools path to PATH, this allows to access bpftool in the VM; - export the kernel build directory to get access to bpf build object. The objective is to be able to start an MPTCP bpf scheduler and validates its behavior using packetdrill. Signed-off-by: Gregory Detal --- entrypoint.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 35043be..0e86e95 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -78,10 +78,14 @@ VIRTME_EXPECT_BOOT_TIMEOUT="300" KERNEL_SRC="${PWD}" +# used to pass environment variables to the VM +BASH_PROFILE="/root/.bash_profile" + VIRTME_WORKDIR="${KERNEL_SRC}/.virtme" VIRTME_BUILD_DIR="${VIRTME_WORKDIR}/build" VIRTME_SCRIPTS_DIR="${VIRTME_WORKDIR}/scripts" VIRTME_PERF_DIR="${VIRTME_BUILD_DIR}/tools/perf" +VIRTME_TOOLS_SBIN_DIR="${VIRTME_BUILD_DIR}/tools/sbin" VIRTME_KCONFIG="${VIRTME_BUILD_DIR}/.config" @@ -613,6 +617,12 @@ prepare() { local mode no_tap=1 no_tap=0 # we want subtests fi + cat < "${BASH_PROFILE}" +export KERNEL_BUILD_DIR="${VIRTME_BUILD_DIR}" +export KERNEL_SRC_DIR="${KERNEL_SRC}" +export PATH="\${PATH}:${VIRTME_TOOLS_SBIN_DIR}" +EOF + cat < "${VIRTME_SCRIPT}" #! /bin/bash