From 1c6be800977ca66d2e471b6e0f80e40c1359d2e0 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 26 Feb 2023 12:09:14 +0900 Subject: [PATCH 1/5] scripts: Deduplicate CH binary fetch script This commit also renames `scripts/fetch_disk_images.sh` to `scripts/fetch_images.sh`. Signed-off-by: Akira Moroo --- scripts/{fetch_disk_images.sh => fetch_images.sh} | 11 +++++++++++ scripts/run_coreboot_integration_tests.sh | 2 +- scripts/run_integration_tests.sh | 10 ++-------- scripts/run_integration_tests_windows.sh | 13 ++++--------- 4 files changed, 18 insertions(+), 18 deletions(-) rename scripts/{fetch_disk_images.sh => fetch_images.sh} (85%) diff --git a/scripts/fetch_disk_images.sh b/scripts/fetch_images.sh similarity index 85% rename from scripts/fetch_disk_images.sh rename to scripts/fetch_images.sh index e0d56cf1..c20be085 100755 --- a/scripts/fetch_disk_images.sh +++ b/scripts/fetch_images.sh @@ -1,6 +1,17 @@ #!/bin/bash set -x +fetch_ch() { + CH_PATH="$1" + CH_VERSION="v23.0" + CH_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor" + if [ ! -f "$CH_PATH" ]; then + wget --quiet $CH_URL -O $CH_PATH + chmod +x $CH_PATH + sudo setcap cap_net_admin+ep $CH_PATH + fi +} + fetch_image() { OS_IMAGE="$1" OS_IMAGE_URL="$2" diff --git a/scripts/run_coreboot_integration_tests.sh b/scripts/run_coreboot_integration_tests.sh index 3c9fa170..062b17ad 100755 --- a/scripts/run_coreboot_integration_tests.sh +++ b/scripts/run_coreboot_integration_tests.sh @@ -4,7 +4,7 @@ set -x RHF_ROOT_DIR=$(cd "$(dirname "$0")/../" && pwd) source "${CARGO_HOME:-$HOME/.cargo}/env" -source "$(dirnam "$0")/fetch_disk_images.sh" +source "$(dirnam "$0")/fetch_images.sh" WORKLOADS_DIR="$HOME/workloads" mkdir -p "$WORKLOADS_DIR" diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index bea7271a..225ca960 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -2,19 +2,13 @@ set -x source "${CARGO_HOME:-$HOME/.cargo}/env" -source $(dirname "$0")/fetch_disk_images.sh +source "$(dirname "$0")/fetch_images.sh" WORKLOADS_DIR="$HOME/workloads" mkdir -p "$WORKLOADS_DIR" -CH_VERSION="v23.0" -CH_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor" CH_PATH="$WORKLOADS_DIR/cloud-hypervisor" -if [ ! -f "$CH_PATH" ]; then - wget --quiet $CH_URL -O $CH_PATH - chmod +x $CH_PATH - sudo setcap cap_net_admin+ep $CH_PATH -fi +fetch_ch "$CH_PATH" fetch_disk_images "$WORKLOADS_DIR" diff --git a/scripts/run_integration_tests_windows.sh b/scripts/run_integration_tests_windows.sh index 6f875ca4..f651bf4b 100755 --- a/scripts/run_integration_tests_windows.sh +++ b/scripts/run_integration_tests_windows.sh @@ -2,27 +2,22 @@ set -x source "${CARGO_HOME:-$HOME/.cargo}/env" +source "$(dirname "$0")/fetch_images.sh" WORKLOADS_DIR="$HOME/workloads" mkdir -p "$WORKLOADS_DIR" WIN_IMAGE_FILE="$WORKLOADS_DIR/windows-server-2019.raw" -CH_VERSION="v20.0" -CH_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor" -CH_PATH="$WORKLOADS_DIR/cloud-hypervisor" -if [ ! -f "$CH_PATH" ]; then - wget --quiet $CH_URL -O $CH_PATH - chmod +x $CH_PATH - sudo setcap cap_net_admin+ep $CH_PATH -fi - # Check if the image is present if [ ! -f "$WIN_IMAGE_FILE" ]; then echo "Windows image not present in the host" exit 1 fi +CH_PATH="$WORKLOADS_DIR/cloud-hypervisor" +fetch_ch "$CH_PATH" + # Use device mapper to create a snapshot of the Windows image img_blk_size=$(du -b -B 512 ${WIN_IMAGE_FILE} | awk '{print $1;}') loop_device=$(losetup --find --show --read-only ${WIN_IMAGE_FILE}) From d2f022738d93bfd6f1d543dfe5d406f2a4fb4a79 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 26 Feb 2023 14:56:43 +0900 Subject: [PATCH 2/5] build: Build ssh2 with `vendored-openssl` feature The `vendored-openssl` feature builds static OpenSSL. This is required because Ubuntu 22.04 uses OpenSSL 3, which is not compatible with ssh2. Signed-off-by: Akira Moroo --- Cargo.lock | 14 ++++++++++++-- Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56a57319..e321e055 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -201,15 +201,25 @@ dependencies = [ "autocfg", ] +[[package]] +name = "openssl-src" +version = "111.25.0+1.1.1t" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3173cd3626c43e3854b1b727422a276e568d9ec5fe8cec197822cf52cfb743d6" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" -version = "0.9.61" +version = "0.9.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index 37e9384e..f8a0e2b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,5 +44,5 @@ x86_64 = "0.14.10" [dev-dependencies] dirs = "4.0.0" rand = "0.8.5" -ssh2 = "0.9.4" +ssh2 = { version = "0.9.4", features = ["vendored-openssl"] } tempfile = "3.3.0" From cd326230856524d730d566466725a61e75505399 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 26 Feb 2023 15:03:39 +0900 Subject: [PATCH 3/5] resources: Bump base Ubuntu image from 20.04 to 22.04 Signed-off-by: Akira Moroo --- resources/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/Dockerfile b/resources/Dockerfile index 3361263b..541f3aad 100644 --- a/resources/Dockerfile +++ b/resources/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 as dev +FROM ubuntu:22.04 as dev ARG TARGETARCH ARG RUST_TOOLCHAIN @@ -40,7 +40,6 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \ socat \ dosfstools \ cpio \ - python \ python3 \ python3-setuptools \ ntfs-3g \ @@ -48,7 +47,7 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \ uuid-dev \ m4 \ zlib1g-dev \ - gnat-9 \ + gnat \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ ; fi From ec5d6877b36481ad960d49caad8960f0a7b0aba6 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 26 Feb 2023 15:05:01 +0900 Subject: [PATCH 4/5] resources: Bump coreboot from 4.13 to 4.19 Signed-off-by: Akira Moroo --- resources/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/Dockerfile b/resources/Dockerfile index 541f3aad..8d64f8e5 100644 --- a/resources/Dockerfile +++ b/resources/Dockerfile @@ -6,7 +6,7 @@ ARG RHF_SRC_DIR="/rust-hypervisor-firmware" ARG RHF_BUILD_DIR="$RHF_SRC_DIR/build" ARG CARGO_REGISTRY_DIR="$RHF_BUILD_DIR/cargo_registry" ARG CARGO_GIT_REGISTRY_DIR="$RHF_BUILD_DIR/cargo_git_registry" -ARG COREBOOT_VERSION="4.13" +ARG COREBOOT_VERSION="4.19" ENV CARGO_HOME=/usr/local/rust ENV RUSTUP_HOME=$CARGO_HOME From c95d5c10e478b7985e474c297445ee944894daf5 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 26 Feb 2023 15:06:01 +0900 Subject: [PATCH 5/5] scripts: Remove unused option from build-container Signed-off-by: Akira Moroo --- scripts/dev_cli.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/dev_cli.sh b/scripts/dev_cli.sh index faf8e259..d2f59bbc 100755 --- a/scripts/dev_cli.sh +++ b/scripts/dev_cli.sh @@ -210,9 +210,8 @@ cmd_help() { echo " --release Build the release binary." echo " --volumes Hash separated volumes to be exported. Example --volumes /mnt:/mnt#/myvol:/myvol" echo "" - echo " build-container [--type]" + echo " build-container" echo " Build the Rust Hypervisor Firmware container." - echo " --dev Build dev container. This is the default." echo "" echo " clean []]" echo " Remove the Rust Hypervisor Firmware artifacts." @@ -453,7 +452,6 @@ cmd_build-container() { RUST_TOOLCHAIN="$(rustup show active-toolchain | cut -d ' ' -f1)" $DOCKER_RUNTIME build \ - --target $container_type \ -t $CTR_IMAGE \ -f $BUILD_DIR/Dockerfile \ --build-arg TARGETARCH=$TARGETARCH \