forked from kata-containers/kata-containers
-
Notifications
You must be signed in to change notification settings - Fork 41
tools: Add initial igvm-builder and node-builder/azure-linux scripting #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/agent/samples/policy/yaml/deployment/deployment-docker-busybox.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| all: | ||
| cargo build --release | ||
|
|
||
| clean: | ||
| cargo clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Copyright (c) 2024 Microsoft Corporation | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # this is where the kernel-uvm package installation places bzImage, see SPEC file | ||
| bzimage_bin="/usr/share/cloud-hypervisor/bzImage" | ||
|
|
||
| igvm_extract_folder="igvm-tooling" | ||
| clh_acpi_tables_dir="${igvm_extract_folder}/src/igvm/acpi/acpi-clh/" | ||
| igvmgen_py_file="${igvm_extract_folder}/src/igvm/igvmgen.py" | ||
|
|
||
| igvm_vars="-kernel ${bzimage_bin} -boot_mode x64 -vtl 0 -svme 1 -encrypted_page 1 -pvalidate_opt 1 -acpi ${clh_acpi_tables_dir}" | ||
|
|
||
| igvm_kernel_params_common="dm-mod.create=\"dm-verity,,,ro,0 ${data_sectors} verity 1 /dev/vda1 /dev/vda2 ${data_block_size} ${hash_block_size} ${data_blocks} 0 sha256 ${root_hash} ${salt}\" \ | ||
| root=/dev/dm-0 rootflags=data=ordered,errors=remount-ro ro rootfstype=ext4 panic=1 no_timer_check noreplace-smp systemd.unit=kata-containers.target systemd.mask=systemd-networkd.service \ | ||
| systemd.mask=systemd-networkd.socket agent.enable_signature_verification=false" | ||
| igvm_kernel_prod_params="${igvm_kernel_params_common} quiet" | ||
| igvm_kernel_debug_params="${igvm_kernel_params_common} console=hvc0 systemd.log_target=console agent.log=debug agent.debug_console agent.debug_console_vport=1026" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Copyright (c) 2024 Microsoft Corporation | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| install_igvm() | ||
| { | ||
| if [ -d ${igvm_extract_folder} ]; then | ||
| echo "${igvm_extract_folder} folder already exists, assuming tool is already installed" | ||
| return | ||
| fi | ||
|
|
||
| # the igvm tool on Azure Linux will soon be properly installed through dnf via kata-packages-uvm-build | ||
| # as of now, even when installing with pip3, we cannot delete the source folder as the ACPI tables are not being installed anywhere, hence relying on this folder | ||
| echo "Determining and downloading latest IGVM tooling release, and extracting including ACPI tables" | ||
| IGVM_VER=$(curl -sL "https://api.github.com/repos/microsoft/igvm-tooling/releases/latest" | jq -r .tag_name | sed 's/^v//') | ||
| curl -sL "https://github.com/microsoft/igvm-tooling/archive/refs/tags/${IGVM_VER}.tar.gz" | tar --no-same-owner -xz | ||
| mv igvm-tooling-${IGVM_VER} ${igvm_extract_folder} | ||
|
|
||
| echo "Installing IGVM module msigvm via pip3" | ||
| pushd ${igvm_extract_folder}/src | ||
| pip3 install --no-deps ./ | ||
| popd | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Copyright (c) 2024 Microsoft Corporation | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| set -o errexit | ||
| set -o pipefail | ||
| set -o errtrace | ||
|
|
||
| [ -n "$DEBUG" ] && set -x | ||
|
|
||
| script_dir="$(dirname $(readlink -f $0))" | ||
|
|
||
| # distro-specific config file | ||
| typeset -r CONFIG_SH="config.sh" | ||
|
|
||
| # Name of an optional distro-specific file which, if it exists, must implement the | ||
| # install_igvm() function. | ||
| typeset -r LIB_SH="igvm_lib.sh" | ||
|
|
||
| build_igvm_distro() | ||
| { | ||
| distro_config_dir="${script_dir}/${distro}" | ||
|
|
||
| [ -d "${distro_config_dir}" ] || die "Could not find configuration directory '${distro_config_dir}'" | ||
|
|
||
| if [ -e "${distro_config_dir}/${LIB_SH}" ]; then | ||
| igvm_lib="${distro_config_dir}/${LIB_SH}" | ||
| echo "igvm_lib.sh file found. Loading content" | ||
| source "${igvm_lib}" | ||
| fi | ||
|
|
||
| root_hash_file="${script_dir}/../root_hash.txt" | ||
|
|
||
| if [ ! -f "${root_hash_file}" ]; then | ||
| echo "Could no find image root hash file '${root_hash_file}', aborting" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Reading image dm-verity root hash values" | ||
| root_hash=$(sed -e 's/Root hash:\s*//g;t;d' "${root_hash_file}") | ||
| salt=$(sed -e 's/Salt:\s*//g;t;d' "${root_hash_file}") | ||
| data_blocks=$(sed -e 's/Data blocks:\s*//g;t;d' "${root_hash_file}") | ||
| data_block_size=$(sed -e 's/Data block size:\s*//g;t;d' "${root_hash_file}") | ||
| data_sectors_per_block=$((data_block_size / 512)) | ||
| data_sectors=$((data_blocks * data_sectors_per_block)) | ||
| hash_block_size=$(sed -e 's/Hash block size:\s*//g;t;d' "${root_hash_file}") | ||
|
|
||
| # Source config.sh from distro, depends on root_hash based variables here | ||
| igvm_config="${distro_config_dir}/${CONFIG_SH}" | ||
| source "${igvm_config}" | ||
|
|
||
| echo "Install IGVM tool" | ||
| install_igvm | ||
|
|
||
| echo "Build IGVM (debug) file and calculate reference measurements" | ||
| # we could call into the installed binary '~/.local/bin/igvmgen' when adding to PATH or, better, into 'python3 -m msigvm' | ||
| # however, as we still need the installation directory for the ACPI tables, we leave things as is for now | ||
| # at the same time we seem to need to call pip3 install for invoking the tool at all | ||
| python3 ${igvmgen_py_file} $igvm_vars -o kata-containers-igvm.img -measurement_file igvm-measurement.cose -append "$igvm_kernel_prod_params" -svn $SVN | ||
| python3 ${igvmgen_py_file} $igvm_vars -o kata-containers-igvm-debug.img -measurement_file igvm-debug-measurement.cose -append "$igvm_kernel_debug_params" -svn $SVN | ||
|
|
||
| if [ "${PWD}" -ef "$(readlink -f $OUT_DIR)" ]; then | ||
| echo "OUT_DIR matches with current dir, not moving build artifacts" | ||
| else | ||
| echo "Moving build artifacts to ${OUT_DIR}" | ||
| mv igvm-measurement.cose kata-containers-igvm.img igvm-debug-measurement.cose kata-containers-igvm-debug.img $OUT_DIR | ||
| fi | ||
| } | ||
|
|
||
| distro="azure-linux" | ||
|
|
||
| while getopts ":o:s:" OPTIONS; do | ||
| case "${OPTIONS}" in | ||
| o ) OUT_DIR=$OPTARG ;; | ||
| s ) SVN=$OPTARG ;; | ||
| \? ) | ||
| echo "Error - Invalid Option: -$OPTARG" 1>&2 | ||
| exit 1 | ||
| ;; | ||
| : ) | ||
| echo "Error - Invalid Option: -$OPTARG requires an argument" 1>&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| echo "IGVM builder script" | ||
| echo "-- OUT_DIR -> $OUT_DIR" | ||
| echo "-- SVN -> $SVN" | ||
| echo "-- distro -> $distro" | ||
|
|
||
| if [ -n "$distro" ]; then | ||
| build_igvm_distro | ||
| else | ||
| echo "distro must be specified" | ||
| exit 1 | ||
| fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.