From dce4e864732d78e6c96c1fded4387f63c55c5627 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 29 Mar 2024 10:53:08 +0100 Subject: [PATCH 1/4] docker: move virtme after IPRoute2 I don't know which one will be more frequently updated in the future, but if Virtme is quicker to install. So do it after IPRoute2. Signed-off-by: Matthieu Baerts (NGI0) --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 56d929f..0199c75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,10 +71,6 @@ RUN cd /opt && \ cd .. && \ rm -rf "sparse" -# Virtme NG -ARG VIRTME_NG_VERSION="1.22" -RUN pip3 install --break-system-packages virtme-ng=="${VIRTME_NG_VERSION}" - # iproute ARG IPROUTE2_GIT_URL="https://git.kernel.org/pub/scm/network/iproute2/iproute2.git" ARG IPROUTE2_GIT_SHA="v6.8.0" @@ -87,6 +83,10 @@ RUN cd /opt && \ make -j"$(nproc)" -l"$(nproc)" && \ make install +# Virtme NG +ARG VIRTME_NG_VERSION="1.22" +RUN pip3 install --break-system-packages virtme-ng=="${VIRTME_NG_VERSION}" + # to quickly shutdown the VM and more RUN for i in /usr/lib/klibc/bin/*; do \ type "$(basename "${i}")" >/dev/null 2>&1 || ln -sv "${i}" /usr/sbin/; \ From 77d622b2d7b2187bc87094e8bd31e8963267abc8 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 29 Mar 2024 12:27:07 +0100 Subject: [PATCH 2/4] virtme: switch to vng 1.23 By doing that, we suppress the line removing the kconfig, and switch to the new init (with a different expected text). Signed-off-by: Matthieu Baerts (NGI0) --- Dockerfile | 2 +- entrypoint.sh | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0199c75..8dbfb61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,7 +84,7 @@ RUN cd /opt && \ make install # Virtme NG -ARG VIRTME_NG_VERSION="1.22" +ARG VIRTME_NG_VERSION="1.23" RUN pip3 install --break-system-packages virtme-ng=="${VIRTME_NG_VERSION}" # to quickly shutdown the VM and more diff --git a/entrypoint.sh b/entrypoint.sh index 67ef73a..c2d49e8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -114,7 +114,6 @@ VIRTME_RUN_OPTS_DEFAULT=( --arch "${VIRTME_ARCH}" --name "mptcpdev" # hostname --net - --no-virtme-ng-init # see https://github.com/arighi/virtme-ng/issues/90 --memory 2048M --kdir "${VIRTME_BUILD_DIR}" --mods=auto @@ -328,9 +327,6 @@ gen_kconfig() { local type mode kconfig=() vck rc=0 vck=(--arch "${VIRTME_ARCH}" --defconfig --custom "${SELFTESTS_CONFIG}") - # workaround for vng 1.22: https://github.com/arighi/virtme-ng/pull/91 - rm -f "${VIRTME_KCONFIG}" - if [ "${mode}" = "debug" ]; then kconfig+=( -e NET_NS_REFCNT_TRACKER # useful for 'net' tests @@ -1110,14 +1106,13 @@ EOF set timeout "${VIRTME_EXPECT_BOOT_TIMEOUT}" spawn "${VIRTME_RUN_SCRIPT}" -# or with the new init: virtme-ng-init: initialization done expect { - "virtme-init: Setting hostname to mptcpdev...\r" { - send_user "Waiting for the virtme-init to be ready\n" + "virtme-ng-init: initialization done\r" { + send_user "Waiting for the console to be ready\n" send "\r" } timeout { send_user "\n$(log_section_end)" - send_user "Timeout virtme-init: stopping\n" + send_user "Timeout virtme-ng-init: stopping\n" exit 1 } eof { send_user "\n$(log_section_end)" From 7ec45fba33d65cfc09c3fe3885ca432f896c3324 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 29 Mar 2024 12:33:51 +0100 Subject: [PATCH 3/4] ci: remove external net support Not needed to run the tests, we save ~1 second. Signed-off-by: Matthieu Baerts (NGI0) --- entrypoint.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index c2d49e8..448ccd7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -113,7 +113,6 @@ VIRTME_RUN="virtme-run" VIRTME_RUN_OPTS_DEFAULT=( --arch "${VIRTME_ARCH}" --name "mptcpdev" # hostname - --net --memory 2048M --kdir "${VIRTME_BUILD_DIR}" --mods=auto @@ -186,7 +185,7 @@ else } fi -setup_env() { +setup_env() { local net=() log_section_start "Setup environment" # Avoid 'unsafe repository' error: we need to get the rev/tag later from @@ -209,6 +208,8 @@ setup_env() { if [ -n "${INPUT_RUN_TESTS_EXCEPT}" ]; then EXIT_TITLE="${EXIT_TITLE} (except ${INPUT_RUN_TESTS_EXCEPT})" fi + + # The CI doesn't need to access to the outside world, so no '--net' else # avoid override RESULTS_DIR="${RESULTS_DIR_BASE}/$(git rev-parse --short HEAD || echo "UNKNOWN")/${mode}" @@ -216,11 +217,15 @@ setup_env() { mkdir -p "${RESULTS_DIR}" : "${INPUT_CPUS:=2}" # limit to 2 cores for now + + # add net support, can be useful, but delay the start of the tests (~1 sec?) + net=("--net") fi VIRTME_RUN_OPTS=( "${VIRTME_RUN_OPTS_DEFAULT[@]}" --cpus "${INPUT_CPUS}" + "${net[@]}" ) OUTPUT_VIRTME="${RESULTS_DIR}/output.log" From 5cee55f7a4f4e98dbf08fcedee7f20946875dce0 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 29 Mar 2024 12:49:51 +0100 Subject: [PATCH 4/4] kconfig: avoid differences between manual/expect modes Otherwise, the whole kernel has to be recompiled. It should be quick thanks to ccache, but still, best to avoid that. So here, we simply set the panic timeout with a kernel parameter instead of a kconfig depending on the mode. Signed-off-by: Matthieu Baerts (NGI0) --- entrypoint.sh | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 448ccd7..17f7db2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -322,11 +322,10 @@ _add_symlink() { ln -sf "${src}" "${dst}" } -# $1: normal/expect ; $2: mode ; [rest: extra kconfig] -gen_kconfig() { local type mode kconfig=() vck rc=0 - type="${1}" - mode="${2}" - shift 2 +# $1: mode ; [rest: extra kconfig] +gen_kconfig() { local mode kconfig=() vck rc=0 + mode="${1}" + shift log_section_start "Generate kernel config" @@ -347,11 +346,6 @@ gen_kconfig() { local type mode kconfig=() vck rc=0 kconfig+=(-e KFENCE) fi - if [ "${type}" = "expect" ]; then - # Reboot the VM instead of blocking in case of panic - kconfig+=(--set-val PANIC_TIMEOUT -1) - fi - # stop at the first oops, no need to continue in a bad state kconfig+=(-e PANIC_ON_OOPS) @@ -1093,8 +1087,8 @@ run_expect() { VIRTME_EXPECT_TEST_TIMEOUT="${INPUT_EXPECT_TIMEOUT}" fi - # avoid reboot, e.g. in case of panic - VIRTME_RUN_OPTS+=(--qemu-opts -no-reboot) + # force a stop in case of panic, but avoid a reboot in "expect" mode + VIRTME_RUN_OPTS+=(--kopt panic=-1 --qemu-opts -no-reboot) printinfo "Run the virtme script: expect (timeout: ${VIRTME_EXPECT_TEST_TIMEOUT})" @@ -1439,7 +1433,7 @@ go_manual() { local mode printinfo "Start: manual (${mode})" setup_env - gen_kconfig "manual" "${@}" + gen_kconfig "${@}" build prepare "${mode}" run @@ -1457,7 +1451,7 @@ go_expect() { local mode ccache_stat check_last_iproute check_source_exec_all - gen_kconfig "expect" "${@}" + gen_kconfig "${@}" build prepare "${mode}" run_expect