From fdc55725a067450a71bbf853fdfffa7acc77b45a Mon Sep 17 00:00:00 2001 From: Cristian Ciocaltea Date: Tue, 22 Feb 2022 16:58:47 +0200 Subject: [PATCH] ci: Make kernel image available in LAVA for KVM use cases In order to run a VM (e.g. crosvm) through HWCI_TEST_SCRIPT on a LAVA target, it's necessary to download a kernel image on the target device. When HWCI_KVM is set to 'true', we can safely assume HWCI_TEST_SCRIPT contains a command or the path to a script which expects the kernel image to be available under /lava-files/${KERNEL_IMAGE_NAME}. Signed-off-by: Cristian Ciocaltea Reviewed-by: Guilherme Gallo Reviewed-by: Tomeu Vizoso Part-of: --- .gitlab-ci/common/generate-env.sh | 2 ++ .gitlab-ci/common/init-stage2.sh | 8 ++++++++ .gitlab-ci/crosvm-runner.sh | 2 +- .gitlab-ci/lava/lava-submit.sh | 5 ++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci/common/generate-env.sh b/.gitlab-ci/common/generate-env.sh index 92d0a89..bb84334 100755 --- a/.gitlab-ci/common/generate-env.sh +++ b/.gitlab-ci/common/generate-env.sh @@ -68,6 +68,8 @@ for var in \ JOB_ARTIFACTS_BASE \ JOB_RESULTS_PATH \ JOB_ROOTFS_OVERLAY_PATH \ + KERNEL_IMAGE_BASE_URL \ + KERNEL_IMAGE_NAME \ LD_LIBRARY_PATH \ LP_NUM_THREADS \ MESA_BASE_TAG \ diff --git a/.gitlab-ci/common/init-stage2.sh b/.gitlab-ci/common/init-stage2.sh index c85e52c..b9eb8b5 100755 --- a/.gitlab-ci/common/init-stage2.sh +++ b/.gitlab-ci/common/init-stage2.sh @@ -12,9 +12,13 @@ set -ex echo -n $HWCI_KERNEL_MODULES | xargs -d, -n1 /usr/sbin/modprobe } +# # Load the KVM module specific to the detected CPU virtualization extensions: # - vmx for Intel VT # - svm for AMD-V +# +# Additionally, download the kernel image to boot the VM via HWCI_TEST_SCRIPT. +# if [ "$HWCI_KVM" = "true" ]; then unset KVM_KERNEL_MODULE grep -qs '\bvmx\b' /proc/cpuinfo && KVM_KERNEL_MODULE=kvm_intel || { @@ -24,6 +28,10 @@ if [ "$HWCI_KVM" = "true" ]; then [ -z "${KVM_KERNEL_MODULE}" ] && \ echo "WARNING: Failed to detect CPU virtualization extensions" || \ modprobe ${KVM_KERNEL_MODULE} + + mkdir -p /lava-files + wget -S --progress=dot:giga -O /lava-files/${KERNEL_IMAGE_NAME} \ + "${KERNEL_IMAGE_BASE_URL}/${KERNEL_IMAGE_NAME}" fi # Fix prefix confusion: the build installs to $CI_PROJECT_DIR, but we expect diff --git a/.gitlab-ci/crosvm-runner.sh b/.gitlab-ci/crosvm-runner.sh index 743afc7..c7c2bf9 100755 --- a/.gitlab-ci/crosvm-runner.sh +++ b/.gitlab-ci/crosvm-runner.sh @@ -91,7 +91,7 @@ crosvm run \ --shared-dir /:my_root:type=fs:writeback=true:timeout=60:cache=always \ --host_ip "192.168.30.1" --netmask "255.255.255.0" --mac "AA:BB:CC:00:00:12" \ --cid ${VSOCK_CID} -p "${CROSVM_KERN_ARGS}" \ - /lava-files/bzImage > ${VSOCK_TEMP_DIR}/crosvm 2>&1 & + /lava-files/${KERNEL_IMAGE_NAME:-bzImage} > ${VSOCK_TEMP_DIR}/crosvm 2>&1 & # Wait for crosvm process to terminate CROSVM_PID=$! diff --git a/.gitlab-ci/lava/lava-submit.sh b/.gitlab-ci/lava/lava-submit.sh index 5b4e0d7..be33abb 100755 --- a/.gitlab-ci/lava/lava-submit.sh +++ b/.gitlab-ci/lava/lava-submit.sh @@ -16,7 +16,10 @@ mkdir -p results/job-rootfs-overlay/ cp artifacts/ci-common/capture-devcoredump.sh results/job-rootfs-overlay/ cp artifacts/ci-common/init-*.sh results/job-rootfs-overlay/ -artifacts/ci-common/generate-env.sh > results/job-rootfs-overlay/set-job-env-vars.sh + +# Prepare env vars for upload. +KERNEL_IMAGE_BASE_URL="https://${BASE_SYSTEM_HOST_PATH}" \ + artifacts/ci-common/generate-env.sh > results/job-rootfs-overlay/set-job-env-vars.sh tar zcf job-rootfs-overlay.tar.gz -C results/job-rootfs-overlay/ . ci-fairy minio login --token-file "${CI_JOB_JWT_FILE}" -- 2.7.4