tests: Build CLH with glibc for Mariner

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 <abombo@microsoft.com>
This commit is contained in:
Aurélien Bombo 2023-06-02 13:17:34 -07:00
parent 80c78eadce
commit 2b59756894
3 changed files with 41 additions and 15 deletions

View File

@ -79,6 +79,7 @@ options:
--build=<asset> :
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 ;;

View File

@ -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
}

View File

@ -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
}