From dbedea5086825cb0fc3b69a3933ff8778768cc07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 11 May 2022 18:50:34 +0200 Subject: [PATCH 1/5] versions: Add virtiofsd entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we're switching to using the rust version of the virtiofsd, let's give it its own entry in the versions.yaml file, as it's no longer part of QEMU. It's important to mention that GitLab doesn't provide a well formed URL for the releases. Instead, it adds there a hash, leading us to have to add the specific link for the tarball. Signed-off-by: Fabiano Fidêncio --- versions.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/versions.yaml b/versions.yaml index 35d8e3c0f..4df02678d 100644 --- a/versions.yaml +++ b/versions.yaml @@ -243,6 +243,17 @@ externals: url: "https://github.com/containerd/nydus-snapshotter" version: "v0.1.0" + virtiofsd: + description: "vhost-user virtio-fs device backend written in Rust" + url: "https://gitlab.com/virtio-fs/virtiofsd" + version: "v1.2.0" + meta: + # From https://gitlab.com/virtio-fs/virtiofsd/-/releases/v1.2.0, + # this is the link labelled virtiofsd-v1.2.0.zip + # + # yamllint disable-line rule:line-length + binary: "https://gitlab.com/virtio-fs/virtiofsd/uploads/b26d9891caac83209a3fdd24bcf2ae86/virtiofsd-v1.2.0.zip" + languages: description: | Details of programming languages required to build system From 8e2042d0556c8a3dce6071b724c01751670c7557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 11 May 2022 19:32:29 +0200 Subject: [PATCH 2/5] tools: add script to pull virtiofsd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right now this is very much x86_64 specific, but I'd like to count on the maintainers of the other architectures to expand it. Also, the name as it's now may be misleading, as we're actually only pulling the binary that's statically built using `musl` and released as part of virtiofsd official releases. But we'll need to build it for the other architectures, thus I'm following the naming of the scripts used by the other components. Signed-off-by: Fabiano Fidêncio --- .../virtiofsd/build-static-virtiofsd.sh | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 tools/packaging/static-build/virtiofsd/build-static-virtiofsd.sh diff --git a/tools/packaging/static-build/virtiofsd/build-static-virtiofsd.sh b/tools/packaging/static-build/virtiofsd/build-static-virtiofsd.sh new file mode 100755 index 000000000..d792e36f6 --- /dev/null +++ b/tools/packaging/static-build/virtiofsd/build-static-virtiofsd.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2022 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +set -o errexit +set -o nounset +set -o pipefail + +ARCH=$(uname -m) + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +source "${script_dir}/../../scripts/lib.sh" + +virtiofsd_version="${virtiofsd_version:-}" + +[ -n "$virtiofsd_version" ] || virtiofsd_version=$(get_from_kata_deps "externals.virtiofsd.version") +[ -n "$virtiofsd_version" ] || die "failed to get virtiofsd version" + +if [ "${ARCH}" != "x86_64" ]; then + info "Only x86_64 binaries are distributed as part of the virtiofsd releases" && exit 1 +fi + +pull_virtiofsd_released_binary() { + info "Download virtiofsd version: ${virtiofsd_version}" + virtiofsd_zip=$(get_from_kata_deps "externals.virtiofsd.meta.binary") + [ -n "${virtiofsd_zip}" ] || die "failed to get virtiofsd binary URL" + + mkdir -p virtiofsd + + pushd virtiofsd + curl --fail -L ${virtiofsd_zip} -o virtiofsd.zip || return 1 + unzip virtiofsd.zip + mv -f target/x86_64-unknown-linux-musl/release/virtiofsd virtiofsd + chmod +x virtiofsd + rm -rf target + rm virtiofsd.zip + popd +} + +pull_virtiofsd_released_binary From c7ac55b6d74b5d1a1060182084c90c6db344e8a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 11 May 2022 21:41:10 +0200 Subject: [PATCH 3/5] dockerbuild: Install unzip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As virtiofsd comes in the `zip` format, let's install unzip in the containers and then be able to access the virtiofsd binary. Signed-off-by: Fabiano Fidêncio --- tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile b/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile index be4c0e816..5514d9a64 100644 --- a/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile +++ b/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile @@ -35,6 +35,7 @@ RUN apt-get update && \ gcc \ git \ make \ + unzip \ xz-utils && \ apt-get clean && rm -rf /var/lib/apt/lists From 71f59f3a7bea276d277a3f5d57a70e4e94663d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 11 May 2022 20:58:58 +0200 Subject: [PATCH 4/5] local-build: Add support for building virtiofsd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As done for the other binaries we release, let's add support for "building" (or pulling down) the static binary we ship as part of the kata-containers static tarball (the same one used by kata-deploy). Right now the virtiofsd is installed in /opt/kata/libexec/virtiofsd, a different path than the virtiofsd that comes with QEMU. Signed-off-by: Fabiano Fidêncio --- tools/packaging/kata-deploy/local-build/Makefile | 6 +++++- .../local-build/kata-deploy-binaries.sh | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/packaging/kata-deploy/local-build/Makefile b/tools/packaging/kata-deploy/local-build/Makefile index ac3a77714..9d09db049 100644 --- a/tools/packaging/kata-deploy/local-build/Makefile +++ b/tools/packaging/kata-deploy/local-build/Makefile @@ -27,7 +27,8 @@ all: cloud-hypervisor-tarball \ qemu-tarball \ rootfs-image-tarball \ rootfs-initrd-tarball \ - shim-v2-tarball + shim-v2-tarball \ + virtiofsd-tarball %-tarball-build: $(MK_DIR)/dockerbuild/install_yq.sh $(call BUILD,$*) @@ -57,6 +58,9 @@ rootfs-initrd-tarball: shim-v2-tarball: ${MAKE} $@-build +virtiofsd-tarball: + ${MAKE} $@-build + merge-builds: $(MK_DIR)/kata-deploy-merge-builds.sh 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 a73b2d2c2..2809d6e7d 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -26,6 +26,7 @@ readonly firecracker_builder="${static_build_dir}/firecracker/build-static-firec readonly kernel_builder="${static_build_dir}/kernel/build.sh" readonly qemu_builder="${static_build_dir}/qemu/build-static-qemu.sh" readonly shimv2_builder="${static_build_dir}/shim-v2/build.sh" +readonly virtiofsd_builder="${static_build_dir}/virtiofsd/build-static-virtiofsd.sh" readonly rootfs_builder="${repo_root_dir}/tools/packaging/guest-image/build_image.sh" @@ -76,6 +77,7 @@ options: rootfs-image rootfs-initrd shim-v2 + virtiofsd EOF exit "${return_code}" @@ -140,6 +142,15 @@ install_clh() { sudo install -D --owner root --group root --mode 0744 cloud-hypervisor/cloud-hypervisor "${destdir}/opt/kata/bin/cloud-hypervisor" } +# Install static virtiofsd asset +install_virtiofsd() { + info "build static virtiofsd" + "${virtiofsd_builder}" + info "Install static virtiofsd" + mkdir -p "${destdir}/opt/kata/libexec/" + sudo install -D --owner root --group root --mode 0744 virtiofsd/virtiofsd "${destdir}/opt/kata/libexec/virtiofsd" +} + #Install all components that are not assets install_shimv2() { GO_VERSION="$(yq r ${versions_yaml} languages.golang.meta.newest-version)" @@ -166,6 +177,7 @@ handle_build() { install_kernel install_qemu install_shimv2 + install_virtiofsd ;; cloud-hypervisor) install_clh ;; @@ -184,6 +196,8 @@ handle_build() { shim-v2) install_shimv2 ;; + virtiofsd) install_virtiofsd ;; + *) die "Invalid build target ${build_target}" ;; @@ -221,6 +235,7 @@ main() { rootfs-image rootfs-initrd shim-v2 + virtiofsd ) silent=false while getopts "hs-:" opt; do From a475956abd5f4eb46ea0f90a0faafb7c1edf345a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 11 May 2022 21:09:07 +0200 Subject: [PATCH 5/5] workflows: Add support for building virtiofsd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As already done for the other assets we rely on, let's build (well, pull in this very specific case) the virtiofsd binary, as we're relying on its standlone rust version from now on. Fixes: #4234 Signed-off-by: Fabiano Fidêncio --- .github/workflows/kata-deploy-push.yaml | 1 + .github/workflows/kata-deploy-test.yaml | 1 + .github/workflows/release.yaml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/kata-deploy-push.yaml b/.github/workflows/kata-deploy-push.yaml index 54110d2c7..090f89195 100644 --- a/.github/workflows/kata-deploy-push.yaml +++ b/.github/workflows/kata-deploy-push.yaml @@ -24,6 +24,7 @@ jobs: - firecracker - rootfs-image - rootfs-initrd + - virtiofsd steps: - uses: actions/checkout@v2 - name: Install docker diff --git a/.github/workflows/kata-deploy-test.yaml b/.github/workflows/kata-deploy-test.yaml index c0a9b98b3..4a9c06de1 100644 --- a/.github/workflows/kata-deploy-test.yaml +++ b/.github/workflows/kata-deploy-test.yaml @@ -47,6 +47,7 @@ jobs: - rootfs-image - rootfs-initrd - shim-v2 + - virtiofsd steps: - name: get-PR-ref id: get-PR-ref diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 56cc89538..81f05942c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,6 +17,7 @@ jobs: - rootfs-image - rootfs-initrd - shim-v2 + - virtiofsd steps: - uses: actions/checkout@v2 - name: Install docker