From 924bda0c61d60d6fd089b390aef108d132b6a596 Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Wed, 8 May 2019 17:09:00 -0700 Subject: [PATCH 1/3] nemu: add support for static build of nemu Fixes: #401 Signed-off-by: Eric Ernst --- static-build/nemu/Dockerfile | 56 +++++++++++++++++++++++ static-build/nemu/Makefile | 13 ++++++ static-build/nemu/build-static-nemu.sh | 63 ++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 static-build/nemu/Dockerfile create mode 100644 static-build/nemu/Makefile create mode 100755 static-build/nemu/build-static-nemu.sh diff --git a/static-build/nemu/Dockerfile b/static-build/nemu/Dockerfile new file mode 100644 index 000000000..186e77bfc --- /dev/null +++ b/static-build/nemu/Dockerfile @@ -0,0 +1,56 @@ +# Copyright (c) 2019 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +from ubuntu:18.04 + +ARG NEMU_REPO +ARG NEMU_VERSION +ARG NEMU_OVMF + +WORKDIR /root/nemu +RUN apt-get update +RUN apt-get install -y \ + autoconf \ + automake \ + bc \ + bison \ + cpio \ + flex \ + gawk \ + libaudit-dev \ + libcap-dev \ + libcap-ng-dev \ + libdw-dev \ + libelf-dev \ + libglib2.0-0 \ + libglib2.0-dev \ + libglib2.0-dev git \ + libltdl-dev \ + libpixman-1-dev \ + libtool \ + pkg-config \ + pkg-config \ + python \ + python-dev \ + rsync \ + wget \ + zlib1g-dev + +RUN cd .. && git clone --depth=1 "${NEMU_REPO}" nemu +RUN git checkout "${NEMU_VERSION}" +RUN git clone https://github.com/qemu/capstone.git capstone +RUN git clone https://github.com/qemu/keycodemapdb.git ui/keycodemapdb + +ADD configure-hypervisor.sh /root/configure-hypervisor.sh + +RUN PREFIX=/opt/kata /root/configure-hypervisor.sh -s kata-nemu | xargs ./configure \ + --with-pkgversion=kata-static + +RUN make -j$(nproc) +RUN make install DESTDIR=/tmp/nemu-static + +RUN wget "${NEMU_OVMF}" && mv OVMF.fd /tmp/nemu-static/opt/kata/share/kata-nemu/ +RUN mv /tmp/nemu-static/opt/kata/bin/qemu-system-x86_64 /tmp/nemu-static/opt/kata/bin/nemu-system-x86_64 + +RUN cd /tmp/nemu-static && tar -czvf kata-nemu-static.tar.gz * diff --git a/static-build/nemu/Makefile b/static-build/nemu/Makefile new file mode 100644 index 000000000..97003df87 --- /dev/null +++ b/static-build/nemu/Makefile @@ -0,0 +1,13 @@ +#Copyright (c) 2019 Intel Corporation +# +#SPDX-License-Identifier: Apache-2.0 +# + +MK_DIR :=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +CONFIG_DIR := $(MK_DIR)/../../scripts/ + +build: + "$(MK_DIR)/build-static-nemu.sh" + +clean: + rm -f kata-nemu-static.tar.gz diff --git a/static-build/nemu/build-static-nemu.sh b/static-build/nemu/build-static-nemu.sh new file mode 100755 index 000000000..339bbe327 --- /dev/null +++ b/static-build/nemu/build-static-nemu.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# Copyright (c) 2019 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" + +config_dir="${script_dir}/../../scripts/" + +nemu_repo="${nemu_repo:-}" +nemu_version="${nemu_version:-}" +nemu_ovmf_repo="${nemu_ovmf_repo:-}" +nemu_ovmf_version="${nemu_ovmf_version:-}" + +if [ -z "$nemu_repo" ]; then + info "Get nemu information from runtime versions.yaml" + nemu_url=$(get_from_kata_deps "assets.hypervisor.nemu.url") + [ -n "$nemu_url" ] || die "failed to get nemu url" + nemu_repo="${nemu_url}.git" +fi +[ -n "$nemu_repo" ] || die "failed to get nemu repo" + +[ -n "$nemu_version" ] || nemu_version=$(get_from_kata_deps "assets.hypervisor.nemu.version") +[ -n "$nemu_version" ] || die "failed to get nemu version" + +if [ -z "$nemu_ovmf_repo" ]; then + info "Get nemu information from runtime versions.yaml" + nemu_ovmf_repo=$(get_from_kata_deps "assets.hypervisor.nemu-ovmf.url") + [ -n "$nemu_ovmf_repo" ] || die "failed to get nemu ovmf repo url" +fi + +if [ -z "$nemu_ovmf_version" ]; then + nemu_ovmf_version=$(get_from_kata_deps "assets.hypervisor.nemu-ovmf.version") + [ -n "$nemu_ovmf_version" ] || die "failed to get nemu ovmf version" +fi + +nemu_ovmf_release="${nemu_ovmf_repo}/releases/download/${nemu_ovmf_version}/OVMF.fd" +info "Build ${nemu_repo} version: ${nemu_version}" + +http_proxy="${http_proxy:-}" +https_proxy="${https_proxy:-}" + +docker build \ + --build-arg http_proxy="${http_proxy}" \ + --build-arg https_proxy="${https_proxy}" \ + --build-arg NEMU_REPO="${nemu_repo}" \ + --build-arg NEMU_VERSION="${nemu_version}" \ + --build-arg NEMU_OVMF="${nemu_ovmf_release}" \ + "${config_dir}" \ + -f "${script_dir}/Dockerfile" \ + -t nemu-static + +docker run \ + -i \ + -v "${PWD}":/share nemu-static \ + mv /tmp/nemu-static/kata-nemu-static.tar.gz /share/ From 255bae15150ce382d769a9d7866f9bee07e6f742 Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Wed, 8 May 2019 18:44:45 -0700 Subject: [PATCH 2/3] nemu: add virtiofsd to nemu static binary add virtiofsd as part of the nemu static build Signed-off-by: Eric Ernst --- static-build/nemu/Dockerfile | 3 +++ static-build/nemu/build-static-nemu.sh | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/static-build/nemu/Dockerfile b/static-build/nemu/Dockerfile index 186e77bfc..1691a2a75 100644 --- a/static-build/nemu/Dockerfile +++ b/static-build/nemu/Dockerfile @@ -7,6 +7,8 @@ from ubuntu:18.04 ARG NEMU_REPO ARG NEMU_VERSION ARG NEMU_OVMF +ARG VIRTIOFSD_RELEASE +ARG VIRTIOFSD WORKDIR /root/nemu RUN apt-get update @@ -52,5 +54,6 @@ RUN make install DESTDIR=/tmp/nemu-static RUN wget "${NEMU_OVMF}" && mv OVMF.fd /tmp/nemu-static/opt/kata/share/kata-nemu/ RUN mv /tmp/nemu-static/opt/kata/bin/qemu-system-x86_64 /tmp/nemu-static/opt/kata/bin/nemu-system-x86_64 +RUN wget "${VIRTIOFSD_RELEASE}/${VIRTIOFSD}" && chmod +x ${VIRTIOFSD} && mv ${VIRTIOFSD} /tmp/nemu-static/opt/kata/bin/ RUN cd /tmp/nemu-static && tar -czvf kata-nemu-static.tar.gz * diff --git a/static-build/nemu/build-static-nemu.sh b/static-build/nemu/build-static-nemu.sh index 339bbe327..c8c304961 100755 --- a/static-build/nemu/build-static-nemu.sh +++ b/static-build/nemu/build-static-nemu.sh @@ -21,9 +21,7 @@ nemu_ovmf_version="${nemu_ovmf_version:-}" if [ -z "$nemu_repo" ]; then info "Get nemu information from runtime versions.yaml" - nemu_url=$(get_from_kata_deps "assets.hypervisor.nemu.url") - [ -n "$nemu_url" ] || die "failed to get nemu url" - nemu_repo="${nemu_url}.git" + nemu_repo=$(get_from_kata_deps "assets.hypervisor.nemu.url") fi [ -n "$nemu_repo" ] || die "failed to get nemu repo" @@ -41,6 +39,8 @@ if [ -z "$nemu_ovmf_version" ]; then [ -n "$nemu_ovmf_version" ] || die "failed to get nemu ovmf version" fi +nemu_virtiofsd_binary="virtiofsd-x86_64" +nemu_virtiofsd_release="${nemu_repo}/releases/download/${nemu_version}" nemu_ovmf_release="${nemu_ovmf_repo}/releases/download/${nemu_ovmf_version}/OVMF.fd" info "Build ${nemu_repo} version: ${nemu_version}" @@ -53,6 +53,8 @@ docker build \ --build-arg NEMU_REPO="${nemu_repo}" \ --build-arg NEMU_VERSION="${nemu_version}" \ --build-arg NEMU_OVMF="${nemu_ovmf_release}" \ + --build-arg VIRTIOFSD_RELEASE="${nemu_virtiofsd_release}" \ + --build-arg VIRTIOFSD="${nemu_virtiofsd_binary}" \ "${config_dir}" \ -f "${script_dir}/Dockerfile" \ -t nemu-static From c769e0572cb8376ffec172587b42ae6744416ae5 Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Thu, 9 May 2019 21:06:27 -0700 Subject: [PATCH 3/3] release: add nemu to kata deploy creation script Add nemu to kata-deploy-binaries.sh Signed-off-by: Eric Ernst --- release/kata-deploy-binaries.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/release/kata-deploy-binaries.sh b/release/kata-deploy-binaries.sh index 374d72e60..e5d4886c9 100755 --- a/release/kata-deploy-binaries.sh +++ b/release/kata-deploy-binaries.sh @@ -104,6 +104,14 @@ install_kernel() { popd >>/dev/null } +# Install static nemu asset +install_nemu() { + info "build static nemu" + "${script_dir}/../static-build/nemu/build-static-nemu.sh" + info "Install static nemu" + tar xf kata-nemu-static.tar.gz -C "${destdir}" +} + # Install static qemu asset install_qemu() { info "build static qemu" @@ -159,6 +167,12 @@ ${prefix}/bin/kata-runtime --kata-config "${prefix}/share/defaults/${project}/co EOT sudo chmod +x kata-qemu + cat <>/dev/null