From 1ef0b7ded0680f34d12d7a2fa64e02d434ff92a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 24 May 2022 14:58:49 +0200 Subject: [PATCH] runtime: Switch to using the rust version of virtiofsd (all but power) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So far this has been done for x86_64. Now that the support for building and testing has been added for all arches, let's do the second part of the switch. We're still not done yet for powerpc, as some a virtifosd crash on the rust version has been found by the maintainer. Fixes: #4258, #4260 Signed-off-by: Fabiano FidĂȘncio --- snap/snapcraft.yaml | 43 ++++++++++++++++--- src/runtime/Makefile | 4 +- .../packaging/scripts/configure-hypervisor.sh | 23 ++++++++++ 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index badfc99eea..60185e8f61 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -52,6 +52,36 @@ parts: curl -LO https://golang.org/dl/${tarfile} tar -xf ${tarfile} --strip-components=1 + rustdeps: + after: [metadata] + plugin: nil + prime: + - -* + build-packages: + - curl + override-build: | + source "${SNAPCRAFT_PROJECT_DIR}/snap/local/snap-common.sh" + + # put everything in stage + cd "${SNAPCRAFT_STAGE}" + + version="$(${yq} r ${kata_dir}/versions.yaml languages.rust.meta.newest-version)" + if ! command -v rustup > /dev/null; then + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${version} + fi + + export PATH=${PATH}:${HOME}/.cargo/bin + rustup toolchain install ${version} + rustup default ${version} + if [ "${arch}" == "ppc64le" ] || [ "${arch}" == "s390x" ] ; then + [ ${arch} == "ppc64le"] && arch="powerpc64le" + rustup target add ${arch}-unknown-linux-gnu + else + rustup target add ${arch}-unknown-linux-musl + $([ "$(whoami)" != "root" ] && echo sudo) ln -sf /usr/bin/g++ /bin/musl-g++ + fi + rustup component add rustfmt + image: after: [godeps, qemu, kernel] plugin: nil @@ -271,25 +301,26 @@ parts: virtiofsd: plugin: nil - after: [godeps] + after: [godeps, rustdeps] override-build: | source "${SNAPCRAFT_PROJECT_DIR}/snap/local/snap-common.sh" - # Currently, only one platform uses the new rust virtiofsd. The - # others make use of QEMU's C implementation. + # Currently, powerpc makes use of the QEMU's C implementation. + # The other platforms make use of the new rust virtiofsd. # # See "tools/packaging/scripts/configure-hypervisor.sh". - if [ "${arch}" = 'x86_64' ] + if [ "${arch}" == "ppc64le" ] then - echo "INFO: Building rust version of virtiofsd" - else echo "INFO: Building QEMU's C version of virtiofsd" # Handled by the 'qemu' part, so nothing more to do here. exit 0 + else + echo "INFO: Building rust version of virtiofsd" fi cd "${kata_dir}" + export PATH=${PATH}:${HOME}/.cargo/bin # Download the rust implementation of virtiofsd tools/packaging/static-build/virtiofsd/build-static-virtiofsd.sh sudo install \ diff --git a/src/runtime/Makefile b/src/runtime/Makefile index 85f9bbd8ab..6abaa362b8 100644 --- a/src/runtime/Makefile +++ b/src/runtime/Makefile @@ -175,9 +175,9 @@ DEFVALIDENTROPYSOURCES := [\"/dev/urandom\",\"/dev/random\",\"\"] DEFDISABLEBLOCK := false DEFSHAREDFS_CLH_VIRTIOFS := virtio-fs DEFSHAREDFS_QEMU_VIRTIOFS := virtio-fs -DEFVIRTIOFSDAEMON := $(LIBEXECDIR)/kata-qemu/virtiofsd -ifeq ($(ARCH),amd64) DEFVIRTIOFSDAEMON := $(LIBEXECDIR)/virtiofsd +ifeq ($(ARCH),ppc64le) +DEFVIRTIOFSDAEMON := $(LIBEXECDIR)/kata-qemu/virtiofsd endif DEFVALIDVIRTIOFSDAEMONPATHS := [\"$(DEFVIRTIOFSDAEMON)\"] # Default DAX mapping cache size in MiB diff --git a/tools/packaging/scripts/configure-hypervisor.sh b/tools/packaging/scripts/configure-hypervisor.sh index 6bf4c1107e..e1e17ef014 100755 --- a/tools/packaging/scripts/configure-hypervisor.sh +++ b/tools/packaging/scripts/configure-hypervisor.sh @@ -317,6 +317,29 @@ generate_qemu_options() { # Don't build the qemu-io, qemu-nbd and qemu-image tools qemu_options+=(size:--disable-tools) + # Kata Containers may be configured to use the virtiofs daemon. + # + # But since QEMU 5.2 the daemon is built as part of the tools set + # (disabled with --disable-tools) thus it needs to be explicitely + # enabled. + # + # From Kata Containers 2.5.0-alpha2 all arches but powerpc have been + # using the new implementation of virtiofs daemon, which is not part + # of QEMU. + # For the powwer, at least for now, keep building virtiofsd while + # building QEMU. + case "$arch" in + aarch64) + ;; + x86_64) + ;; + ppc64le) + qemu_options+=(functionality:--enable-virtiofsd) + ;; + s390x) + ;; + esac + qemu_options+=(functionality:--enable-virtfs) # Don't build linux-user bsd-user