diff --git a/Dockerfile b/Dockerfile index b39d39f..300c891 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,8 @@ RUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential libncurses5-dev gcc libssl-dev bc bison automake \ libelf-dev flex git curl tar hashalot qemu-kvm sudo expect \ - python3 python3-pkg-resources busybox \ + python3 python3-pip python3-pkg-resources file virtiofsd \ + busybox-static coreutils python3-requests libvirt-clients udev \ iputils-ping ethtool klibc-utils kbd rsync ccache netcat-openbsd \ ca-certificates gnupg2 net-tools kmod \ libdbus-1-dev libnl-genl-3-dev libibverbs-dev \ @@ -29,14 +30,6 @@ RUN apt-get update && \ && \ apt-get clean -# virtme -ARG VIRTME_GIT_URL="https://github.com/matttbe/virtme.git" -ARG VIRTME_GIT_SHA="57c440a1dce4476638d67a2d1aead5bdcced0de7" # include a fix for modules on linux >= 6.2 and QEmu > 6 -RUN cd /opt && \ - git clone "${VIRTME_GIT_URL}" && \ - cd virtme && \ - git checkout "${VIRTME_GIT_SHA}" - # byobu (not to have a dep to iproute2) ARG BYOBU_URL="https://github.com/dustinkirkland/byobu/archive/refs/tags/6.12.tar.gz" ARG BYOBU_SUM="abb000331858609dfda9214115705506249f69237625633c80487abe2093dd45 byobu.tar.gz" @@ -77,6 +70,10 @@ 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" diff --git a/entrypoint.sh b/entrypoint.sh index 095836e..94d06c4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -107,19 +107,20 @@ mkdir -p \ "${VIRTME_PERF_DIR}" \ "${CCACHE_DIR}" -VIRTME_PROG_PATH="/opt/virtme" -VIRTME_CONFIGKERNEL="${VIRTME_PROG_PATH}/virtme-configkernel" -VIRTME_RUN="${VIRTME_PROG_PATH}/virtme-run" +VIRTME_CONFIGKERNEL="virtme-configkernel" +VIRTME_RUN="virtme-run" 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 - --rwdir "." + --rw # Don't use "rwdir", it will use 9p ; in a container, we can use rw --pwd --show-command + --verbose --show-boot-console --kopt mitigations=off ) @@ -317,13 +318,18 @@ _add_symlink() { } # $1: normal/expect ; $2: mode ; [rest: extra kconfig] -gen_kconfig() { local type mode kconfig=() rc=0 +gen_kconfig() { local type mode kconfig=() vck rc=0 type="${1}" mode="${2}" shift 2 log_section_start "Generate kernel config" + 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 @@ -332,13 +338,11 @@ gen_kconfig() { local type mode kconfig=() rc=0 -e BOOTPARAM_HUNG_TASK_PANIC # instead of blocking ) - _make_o defconfig debug.config || rc=${?} + vck+=(--custom kernel/configs/debug.config) else # low-overhead sampling-based memory safety error detector. # Only in non-debug: KASAN is more precise kconfig+=(-e KFENCE) - - _make_o defconfig "${VIRTME_ARCH}_defconfig" || rc=${?} fi if [ "${type}" = "expect" ]; then @@ -357,9 +361,7 @@ gen_kconfig() { local type mode kconfig=() rc=0 # We need more debug info but it is slow to generate if [ "${mode}" = "btf" ]; then - kconfig+=(-e DEBUG_INFO_BTF) - # Extra options are needed for bpftests - ./scripts/kconfig/merge_config.sh -m "${VIRTME_KCONFIG}" "${BPFTESTS_CONFIG}" + vck+=(--custom "${BPFTESTS_CONFIG}") kconfig+=(-e DEBUG_INFO_BTF_MODULES -e MODULE_ALLOW_BTF_MISMATCH) # Fix ./include/linux/if.h:28:10: fatal error: # sys/socket.h: no such file or directory @@ -404,10 +406,7 @@ gen_kconfig() { local type mode kconfig=() rc=0 kconfig+=("${@}") # KBUILD_OUTPUT is used by virtme - "${VIRTME_CONFIGKERNEL}" --arch "${VIRTME_ARCH}" --update || rc=${?} - - # Extra options are needed for kselftests - ./scripts/kconfig/merge_config.sh -m "${VIRTME_KCONFIG}" "${SELFTESTS_CONFIG}" || rc=${?} + "${VIRTME_CONFIGKERNEL}" "${vck[@]}" || rc=${?} ./scripts/config --file "${VIRTME_KCONFIG}" "${kconfig[@]}" || rc=${?} @@ -1095,13 +1094,14 @@ EOF set timeout "${VIRTME_EXPECT_BOOT_TIMEOUT}" spawn "${VIRTME_RUN_SCRIPT}" +# or with the new init: virtme-ng-init: initialization done expect { - "virtme-init: console is ttyS0\r" { - send_user "Waiting for the console to be ready\n" + "virtme-init: Setting hostname to mptcpdev...\r" { + send_user "Waiting for the virtme-init to be ready\n" send "\r" } timeout { send_user "\n$(log_section_end)" - send_user "Timeout ttyS0: stopping\n" + send_user "Timeout virtme-init: stopping\n" exit 1 } eof { send_user "\n$(log_section_end)" @@ -1158,8 +1158,7 @@ expect eof EOF chmod +x "${VIRTME_RUN_EXPECT}" - # for an unknown reason, we cannot use "--script-sh", qemu is not - # started, no debug. As a workaround, we use expect. + # We could use "--script-sh", but we use expect to catch timeout, etc. "${VIRTME_RUN_EXPECT}" | tee "${OUTPUT_VIRTME}" }