From 2b59756894e6e50ce85cf1ae4fd46d9566a049b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bombo?= Date: Fri, 2 Jun 2023 13:17:34 -0700 Subject: [PATCH] tests: Build CLH with glibc for Mariner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables building CLH with glibc and the mshv feature as required for Mariner. At test time, it also configures Kata to use that CLH flavor when running Mariner. Signed-off-by: Aurélien Bombo --- .../local-build/kata-deploy-binaries.sh | 44 ++++++++++++++----- .../kata-deploy/scripts/kata-deploy.sh | 6 ++- .../cloud-hypervisor/build-static-clh.sh | 6 +-- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh index 58e62bb48d..14910f43f4 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -79,6 +79,7 @@ options: --build= : all cloud-hypervisor + cloud-hypervisor-glibc firecracker kernel kernel-dragonball-experimental @@ -447,26 +448,47 @@ install_firecracker() { sudo install -D --owner root --group root --mode 0744 release-${firecracker_version}-${ARCH}/jailer-${firecracker_version}-${ARCH} "${destdir}/opt/kata/bin/jailer" } -# Install static cloud-hypervisor asset -install_clh() { +install_clh_helper() { + libc="${1}" + features="${2}" + suffix="${3:-""}" + install_cached_tarball_component \ - "cloud-hypervisor" \ - "${jenkins_url}/job/kata-containers-main-clh-$(uname -m)/${cached_artifacts_path}" \ + "cloud-hypervisor${suffix}" \ + "${jenkins_url}/job/kata-containers-main-clh-$(uname -m)${suffix}/${cached_artifacts_path}" \ "$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.version")" \ "" \ "${final_tarball_name}" \ "${final_tarball_path}" \ && return 0 - if [[ "${ARCH}" == "x86_64" ]]; then - export features="tdx" - fi - info "build static cloud-hypervisor" - "${clh_builder}" + libc="${libc}" features="${features}" "${clh_builder}" info "Install static cloud-hypervisor" mkdir -p "${destdir}/opt/kata/bin/" - sudo install -D --owner root --group root --mode 0744 cloud-hypervisor/cloud-hypervisor "${destdir}/opt/kata/bin/cloud-hypervisor" + sudo install -D --owner root --group root --mode 0744 cloud-hypervisor/cloud-hypervisor "${destdir}/opt/kata/bin/cloud-hypervisor${suffix}" +} + +# Install static cloud-hypervisor asset +install_clh() { + if [[ "${ARCH}" == "x86_64" ]]; then + features="mshv,tdx" + else + features="" + fi + + install_clh_helper "musl" "${features}" +} + +# Install static cloud-hypervisor-glibc asset +install_clh_glibc() { + if [[ "${ARCH}" == "x86_64" ]]; then + features="mshv" + else + features="" + fi + + install_clh_helper "gnu" "${features}" "-glibc" } # Install static virtiofsd asset @@ -613,7 +635,7 @@ handle_build() { cloud-hypervisor) install_clh ;; - cloud-hypervisor-glibc) ;; + cloud-hypervisor-glibc) install_clh_glibc ;; firecracker) install_firecracker ;; diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 368492bd7c..09d27cc654 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -67,7 +67,11 @@ function install_artifacts() { # Allow Mariner to use custom configuration. if [ "${HOST_OS:-}" == "cbl-mariner" ]; then - sed -i -E 's|(enable_annotations) = .+|\1 = ["enable_iommu", "initrd", "kernel"]|' /opt/kata/share/defaults/kata-containers/configuration-clh.toml + config_path="/opt/kata/share/defaults/kata-containers/configuration-clh.toml" + clh_path="/opt/kata/bin/cloud-hypervisor-glibc" + sed -i -E 's|(enable_annotations) = .+|\1 = ["enable_iommu", "initrd", "kernel"]|' "${config_path}" + sed -i -E "s|(valid_hypervisor_paths) = .+|\1 = [\"${clh_path}\"]|" "${config_path}" + sed -i -E "s|(path) = \".+/cloud-hypervisor\"|\1 = \"${clh_path}\"|" "${config_path}" fi } diff --git a/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh b/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh index 975a517a13..f381897bcd 100755 --- a/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh +++ b/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh @@ -76,12 +76,12 @@ build_clh_from_source() { if [ -n "${features}" ]; then info "Build cloud-hypervisor enabling the following features: ${features}" - ./scripts/dev_cli.sh build --release --libc musl --features "${features}" + ./scripts/dev_cli.sh build --release --libc "${libc}" --features "${features}" else - ./scripts/dev_cli.sh build --release --libc musl + ./scripts/dev_cli.sh build --release --libc "${libc}" fi rm -f cloud-hypervisor - cp build/cargo_target/$(uname -m)-unknown-linux-musl/release/cloud-hypervisor . + cp build/cargo_target/$(uname -m)-unknown-linux-${libc}/release/cloud-hypervisor . popd }