packaging: Allow building QEMU for CC

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 <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2022-06-30 14:16:36 +02:00
parent c4cc16efcd
commit b307531c29
3 changed files with 46 additions and 0 deletions

View File

@ -76,6 +76,9 @@ cc-cloud-hypervisor-tarball:
cc-kernel-tarball: cc-kernel-tarball:
${MAKE} $@-build ${MAKE} $@-build
cc-qemu-tarball:
${MAKE} $@-build
cc-rootfs-image-tarball: cc-rootfs-image-tarball:
${MAKE} $@-build ${MAKE} $@-build

View File

@ -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 rootfs_builder="${repo_root_dir}/tools/packaging/guest-image/build_image.sh"
readonly cc_prefix="/opt/confidential-containers" readonly cc_prefix="/opt/confidential-containers"
readonly qemu_cc_builder="${static_build_dir}/qemu/build-static-qemu-cc.sh"
ARCH=$(uname -m) ARCH=$(uname -m)
@ -114,6 +115,15 @@ install_cc_kernel() {
DESTDIR="${destdir}" PREFIX="${cc_prefix}" "${kernel_builder}" -f -v "${kernel_version}" 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 all components that are not assets
install_cc_shimv2() { install_cc_shimv2() {
GO_VERSION="$(yq r ${versions_yaml} languages.golang.meta.newest-version)" GO_VERSION="$(yq r ${versions_yaml} languages.golang.meta.newest-version)"
@ -223,6 +233,8 @@ handle_build() {
cc-kernel) install_cc_kernel ;; cc-kernel) install_cc_kernel ;;
cc-qemu) install_cc_qemu ;;
cc-rootfs-image) install_cc_image ;; cc-rootfs-image) install_cc_image ;;
cc-shim-v2) install_cc_shimv2 ;; cc-shim-v2) install_cc_shimv2 ;;

View File

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