From 906580ee92cd9ccda1afd771261b166e387ea6bf Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 11 Nov 2024 10:07:39 +0800 Subject: [PATCH] scripts: Add prepare_linux function `prepare_linux` checks if a `--build-guest-kernel` option is present, and build kernel from `cloud-hypervisor/linux.git`. Otherwise, it will invoke `download_linux` to use pre-built kernel. Signed-off-by: Ruoqing He --- scripts/test-util.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/test-util.sh b/scripts/test-util.sh index 2c0ff9544..b9ecf49b7 100644 --- a/scripts/test-util.sh +++ b/scripts/test-util.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash hypervisor="kvm" test_filter="" +build_kernel=false # Checkout source code of a GIT repo with specified branch and commit # Args: @@ -75,11 +76,13 @@ cmd_help() { echo "" echo " --hypervisor Underlying hypervisor. Options kvm, mshv" echo " --test-filter Tests to run" + echo " --build-guest-kernel Build guest kernel from source instead of downloading pre-built" echo "" echo " --help Display this help message." echo "" } +# shellcheck disable=SC2034 process_common_args() { while [ $# -gt 0 ]; do case "$1" in @@ -93,9 +96,11 @@ process_common_args() { ;; "--test-filter") shift - # shellcheck disable=SC2034 test_filter="$1" ;; + "--build-guest-kernel") + build_kernel=true + ;; "--") { shift break @@ -149,6 +154,18 @@ download_linux() { popd || exit } +prepare_linux() { + if [ "$build_kernel" = true ]; then + echo "Building kernel from source" + build_custom_linux + echo "Using kernel built from source" + else + echo "Downloading pre-built kernel from GitHub" + download_linux + echo "Using kernel downloaded from GitHub" + fi +} + download_ovmf() { OVMF_FW_TAG="ch-6624aa331f" OVMF_FW_URL="https://github.com/cloud-hypervisor/edk2/releases/download/$OVMF_FW_TAG/CLOUDHV.fd"