From b307531c29d951c18f993c41ff344721f6e42b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 30 Jun 2022 14:16:36 +0200 Subject: [PATCH] packaging: Allow building QEMU for CC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're adding a new target for building QEMU for CC, but it's important to note that the only difference between this one and the "vanilla" build is the installation path. The reason we're taking this approach is because the first release target for CC doesn't include TEE support. We had to also include a new builder for QEMU, a specific one for CC, as for now that's the easiest way to override the prefix in a way that we'll be easily able to expand the script to support TEE capable builds in the very near future. Fixes: #4568 Signed-off-by: Fabiano FidĂȘncio --- .../kata-deploy/local-build/Makefile | 3 ++ .../local-build/kata-deploy-binaries.sh | 12 +++++++ .../static-build/qemu/build-static-qemu-cc.sh | 31 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100755 tools/packaging/static-build/qemu/build-static-qemu-cc.sh diff --git a/tools/packaging/kata-deploy/local-build/Makefile b/tools/packaging/kata-deploy/local-build/Makefile index 97a1a580e9..ba9190db88 100644 --- a/tools/packaging/kata-deploy/local-build/Makefile +++ b/tools/packaging/kata-deploy/local-build/Makefile @@ -76,6 +76,9 @@ cc-cloud-hypervisor-tarball: cc-kernel-tarball: ${MAKE} $@-build +cc-qemu-tarball: + ${MAKE} $@-build + cc-rootfs-image-tarball: ${MAKE} $@-build 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 7bc556dbc6..743e066e9e 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -31,6 +31,7 @@ readonly virtiofsd_builder="${static_build_dir}/virtiofsd/build-static-virtiofsd readonly rootfs_builder="${repo_root_dir}/tools/packaging/guest-image/build_image.sh" readonly cc_prefix="/opt/confidential-containers" +readonly qemu_cc_builder="${static_build_dir}/qemu/build-static-qemu-cc.sh" ARCH=$(uname -m) @@ -114,6 +115,15 @@ install_cc_kernel() { DESTDIR="${destdir}" PREFIX="${cc_prefix}" "${kernel_builder}" -f -v "${kernel_version}" } +# Install static CC qemu asset +install_cc_qemu() { + info "build static CC qemu" + export qemu_repo="$(yq r $versions_yaml assets.hypervisor.qemu.url)" + export qemu_version="$(yq r $versions_yaml assets.hypervisor.qemu.version)" + "${qemu_cc_builder}" + tar xvf "${builddir}/kata-static-qemu-cc.tar.gz" -C "${destdir}" +} + #Install all components that are not assets install_cc_shimv2() { GO_VERSION="$(yq r ${versions_yaml} languages.golang.meta.newest-version)" @@ -223,6 +233,8 @@ handle_build() { cc-kernel) install_cc_kernel ;; + cc-qemu) install_cc_qemu ;; + cc-rootfs-image) install_cc_image ;; cc-shim-v2) install_cc_shimv2 ;; diff --git a/tools/packaging/static-build/qemu/build-static-qemu-cc.sh b/tools/packaging/static-build/qemu/build-static-qemu-cc.sh new file mode 100755 index 0000000000..44a4056d32 --- /dev/null +++ b/tools/packaging/static-build/qemu/build-static-qemu-cc.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2022 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +set -o errexit +set -o nounset +set -o pipefail + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +source "${script_dir}/../../scripts/lib.sh" + +qemu_repo="${qemu_repo:-}" +qemu_version="${qemu_version:-}" + +export prefix="/opt/confidential-containers/" + +if [ -z "$qemu_repo" ]; then + info "Get qemu information from runtime versions.yaml" + qemu_url=$(get_from_kata_deps "assets.hypervisor.qemu.url") + [ -n "$qemu_url" ] || die "failed to get qemu url" + qemu_repo="${qemu_url}.git" +fi +[ -n "$qemu_repo" ] || die "failed to get qemu repo" + +[ -n "$qemu_version" ] || qemu_version=$(get_from_kata_deps "assets.hypervisor.qemu.version") +[ -n "$qemu_version" ] || die "failed to get qemu version" + +"${script_dir}/build-base-qemu.sh" "${qemu_repo}" "${qemu_version}" "" "kata-static-qemu-cc.tar.gz"