From 0f43ec8ff79472d91acfe73717ddfc07ce1b5dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 30 Jan 2023 13:59:16 +0100 Subject: [PATCH 1/2] Revert "packaging: Don't build runtime-rs if no RUST_VERSION is provided" This reverts commit 299829aec09a1f237b85bc6cebd49980766ef33f, as we'll start adding TDX support for the runtime-rs. --- .../local-build/kata-deploy-binaries.sh | 2 ++ tools/packaging/static-build/shim-v2/build.sh | 22 +++++++++---------- .../static-build/shim-v2/install_go_rust.sh | 12 +++++----- 3 files changed, 17 insertions(+), 19 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 5dd3f0968a..94ccb105ec 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -344,7 +344,9 @@ install_cc_shimv2() { && return 0 GO_VERSION="$(yq r ${versions_yaml} languages.golang.meta.newest-version)" + RUST_VERSION="$(yq r ${versions_yaml} languages.rust.meta.newest-version)" export GO_VERSION + export RUST_VERSION export REMOVE_VMM_CONFIGS="acrn fc" extra_opts="DEFSERVICEOFFLOAD=true" diff --git a/tools/packaging/static-build/shim-v2/build.sh b/tools/packaging/static-build/shim-v2/build.sh index bedf55d92c..10df1a0b30 100755 --- a/tools/packaging/static-build/shim-v2/build.sh +++ b/tools/packaging/static-build/shim-v2/build.sh @@ -15,7 +15,7 @@ source "${script_dir}/../../scripts/lib.sh" readonly kernel_builder="${repo_root_dir}/tools/packaging/kernel/build-kernel.sh" GO_VERSION=${GO_VERSION} -RUST_VERSION=${RUST_VERSION:-} +RUST_VERSION=${RUST_VERSION} DESTDIR=${DESTDIR:-${PWD}} PREFIX=${PREFIX:-/opt/kata} @@ -38,18 +38,16 @@ if [ ${arch} = "ppc64le" ]; then arch="ppc64" fi -if [ -n "${RUST_VERSION}" ]; then - sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ - -w "${repo_root_dir}/src/runtime-rs" \ - "${container_image}" \ - bash -c "git config --global --add safe.directory ${repo_root_dir} && make PREFIX=${PREFIX} QEMUCMD=qemu-system-${arch}" - - sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ - -w "${repo_root_dir}/src/runtime-rs" \ - "${container_image}" \ - bash -c "git config --global --add safe.directory ${repo_root_dir} && make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install" -fi +sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ + -w "${repo_root_dir}/src/runtime-rs" \ + "${container_image}" \ + bash -c "git config --global --add safe.directory ${repo_root_dir} && make PREFIX=${PREFIX} QEMUCMD=qemu-system-${arch}" +sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ + -w "${repo_root_dir}/src/runtime-rs" \ + "${container_image}" \ + bash -c "git config --global --add safe.directory ${repo_root_dir} && make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install" + sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ -w "${repo_root_dir}/src/runtime" \ "${container_image}" \ diff --git a/tools/packaging/static-build/shim-v2/install_go_rust.sh b/tools/packaging/static-build/shim-v2/install_go_rust.sh index 1ad638ab37..db192f673b 100755 --- a/tools/packaging/static-build/shim-v2/install_go_rust.sh +++ b/tools/packaging/static-build/shim-v2/install_go_rust.sh @@ -51,13 +51,11 @@ EOF trap finish EXIT rust_version=${2:-} -if [ -n "${rust_version}" ]; then - ARCH=${ARCH:-$(uname -m)} - LIBC=${LIBC:-musl} - curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSLf | sh -s -- -y --default-toolchain ${rust_version} -t ${ARCH}-unknown-linux-${LIBC} - source /root/.cargo/env - rustup target add x86_64-unknown-linux-musl -fi +ARCH=${ARCH:-$(uname -m)} +LIBC=${LIBC:-musl} +curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSLf | sh -s -- -y --default-toolchain ${rust_version} -t ${ARCH}-unknown-linux-${LIBC} +source /root/.cargo/env +rustup target add x86_64-unknown-linux-musl pushd "${tmp_dir}" From 7345c14caa4bdaa35d9fb59d34b2fd4b6f40e720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 30 Jan 2023 14:12:26 +0100 Subject: [PATCH 2/2] caching: Take runtime-rs into consideration when caching shim-v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that TDX work will start coming for runtime-rs, let's also take it into consideration when caching the shim-v2 tarball. Signed-off-by: Fabiano FidĂȘncio --- .../packaging/kata-deploy/local-build/kata-deploy-binaries.sh | 4 +++- tools/packaging/static-build/cache_components.sh | 4 +++- 2 files changed, 6 insertions(+), 2 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 94ccb105ec..e2f538112b 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -330,9 +330,11 @@ install_cc_qemu() { #Install all components that are not assets install_cc_shimv2() { local shim_v2_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime")" + local runtime_rs_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime-rs")" + local protocols_last_commit="$(get_last_modification "${repo_root_dir}/src/libs/protocols")" local golang_version="$(get_from_kata_deps "languages.golang.meta.newest-version")" local rust_version="$(get_from_kata_deps "languages.rust.meta.newest-version")" - local shim_v2_version="${shim_v2_last_commit}-${golang_version}-${rust_version}" + local shim_v2_version="${shim_v2_last_commit}-${protocols_last_commit}-${runtime_rs_last_commit}-${golang_version}-${rust_version}" install_cached_cc_shim_v2 \ "shim-v2" \ diff --git a/tools/packaging/static-build/cache_components.sh b/tools/packaging/static-build/cache_components.sh index 2a9a321e09..4ba95f589d 100755 --- a/tools/packaging/static-build/cache_components.sh +++ b/tools/packaging/static-build/cache_components.sh @@ -111,9 +111,11 @@ cache_rootfs_artifacts() { cache_shim_v2_artifacts() { local shim_v2_tarball_name="kata-static-cc-shim-v2.tar.xz" local shim_v2_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime")" + local protocols_last_commit="$(get_last_modification "${repo_root_dir}/src/libs/protocols")" + local runtime_rs_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime-rs")" local golang_version="$(get_from_kata_deps "languages.golang.meta.newest-version")" local rust_version="$(get_from_kata_deps "languages.rust.meta.newest-version")" - local current_shim_v2_version="${shim_v2_last_commit}-${golang_version}-${rust_version}" + local current_shim_v2_version="${shim_v2_last_commit}-${protocols_last_commit}-${runtime_rs_last_commit}-${golang_version}-${rust_version}" local current_shim_v2_image="$(get_shim_v2_image_name)" create_cache_asset "${shim_v2_tarball_name}" "${current_shim_v2_version}" "${current_shim_v2_image}" "${repo_root_dir}/tools/osbuilder/root_hash_vanilla.txt" "${repo_root_dir}/tools/osbuilder/root_hash_tdx.txt" }