Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions qemu/patches/virtiofsd/0001-add-time-to-seccomp.patch

This file was deleted.

This file was deleted.

10 changes: 8 additions & 2 deletions static-build/cloud-hypervisor/docker-build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ set -o pipefail
script_dir=$(dirname $(readlink -f "$0"))
docker_image="cloud-hypervisor-builder"

sudo docker build -t "${docker_image}" "${script_dir}"
DOCKER_CLI="docker"

if ! command -v docker && command -v podman; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: You might want to add &>/dev/null to both the command calls (here and below) to avoid the paths appearing in build logs?

DOCKER_CLI="podman"
fi

sudo "${DOCKER_CLI}" build -t "${docker_image}" "${script_dir}"

if test -t 1; then
USE_TTY="-ti"
Expand All @@ -20,7 +26,7 @@ else
echo "INFO: not tty build"
fi

sudo docker run \
sudo "${DOCKER_CLI}" run \
--rm \
-v "$(pwd):/$(pwd)" \
-w "$(pwd)" \
Expand Down
36 changes: 28 additions & 8 deletions static-build/qemu-virtiofs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ubuntu:18.04
from ubuntu:20.04

ARG QEMU_VIRTIOFS_REPO
# commit/tag/branch
Expand All @@ -19,37 +19,57 @@ RUN apt-get --no-install-recommends install -y \
flex \
gawk \
libaudit-dev \
libblkid-dev \
libcap-dev \
libcap-ng-dev \
libdw-dev \
libelf-dev \
libffi-dev \
libglib2.0-0 \
libglib2.0-dev \
libglib2.0-dev git \
libltdl-dev \
libmount-dev \
libpixman-1-dev \
libpmem-dev \
libseccomp-dev \
libseccomp2 \
libselinux1-dev \
libtool \
patch \
make \
pkg-config \
pkg-config \
python \
python-dev \
rsync \
seccomp \
libseccomp2 \
zlib1g-dev

RUN cd .. && git clone "${QEMU_VIRTIOFS_REPO}" qemu-virtiofs
RUN git checkout "${QEMU_VIRTIOFS_TAG}"
ADD qemu/patches/virtiofsd/0001-add-time-to-seccomp.patch /root/0001-add-time-to-seccomp.patch
ADD qemu/patches/virtiofsd/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch /root/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch
RUN patch -p1 < /root/0001-add-time-to-seccomp.patch
RUN patch -p1 < /root/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch

ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh
RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | sed -e 's|--enable-rbd||g' -e 's|--disable-seccomp||g' | xargs ./configure \
ADD qemu/patches/ /root/kata_qemu_patches

# Apply experimental specific patches
# Patches to quick fix virtiofs fork
ENV VIRTIOFS_PATCHES_DIR=/root/kata_qemu_patches/${QEMU_VIRTIOFS_TAG}/
RUN find "${VIRTIOFS_PATCHES_DIR}" -name '*.patch' -type f |sort -t- -k1,1n > patches_virtiofs
RUN echo "Patches to apply for virtiofs fixes:"
RUN cat patches_virtiofs
RUN [ ! -s patches_virtiofs ] || git apply $(cat patches_virtiofs)

RUN cat VERSION | awk 'BEGIN{FS=OFS="."}{print $1 "." $2 ".x"}' > stable_branch
RUN echo "root/kata_qemu_patches/$(cat stable_branch)/" > patches_qemu_dir
RUN echo "patches dir $(cat patches_qemu_dir)"
RUN find "$(cat patches_qemu_dir)" -name '*.patch' -type f |sort -t- -k1,1n > patches_qemu
RUN echo "Patches to apply for qemu:"
RUN cat patches_qemu
RUN [ ! -s patches_qemu ] || git apply $(cat patches_qemu )

RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | sed -e 's|--disable-seccomp||g' | xargs ./configure \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just drop this flag from configure-hypervisor itself. It makes sense to have seccomp at this point.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devimc makes use of Kconfig when building the snap. I opened on issue on this, [1], but we should really make sure we are absolutely consistent between specs/debs, snap and static builds.

[1] - #1105

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I think that should be fixed in a separete PR for all places we use it.

--with-pkgversion=kata-static

RUN make -j$(nproc)
RUN make -j$(nproc) virtiofsd
RUN make install DESTDIR=/tmp/qemu-virtiofs-static
Expand Down
12 changes: 9 additions & 3 deletions static-build/qemu-virtiofs/build-static-qemu-virtiofs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/../../scripts/lib.sh"
source "${script_dir}/../qemu.blacklist"

DOCKER_CLI="docker"

if ! command -v docker &>/dev/null && command -v podman &>/dev/null; then
DOCKER_CLI="podman"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why podman..for Fedora?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes :)

fi

kata_version="${kata_version:-}"
packaging_dir="${script_dir}/../.."
qemu_virtiofs_repo=$(get_from_kata_deps "assets.hypervisor.qemu-experimental.url" "${kata_version}")
# This tag will be supported on the runtime versions.yaml
qemu_virtiofs_tag=$(get_from_kata_deps "assets.hypervisor.qemu-experimental.tag" "${kata_version}")
qemu_virtiofs_tag=$(get_from_kata_deps "assets.hypervisor.qemu-experimental.tag" "${kata_version}")
qemu_virtiofs_tar="kata-static-qemu-virtiofsd.tar.gz"
qemu_tmp_tar="kata-static-qemu-virtiofsd-tmp.tar.gz"

Expand All @@ -27,7 +33,7 @@ http_proxy="${http_proxy:-}"
https_proxy="${https_proxy:-}"
prefix="${prefix:-"/opt/kata"}"

sudo docker build \
sudo "${DOCKER_CLI}" build \
--no-cache \
--build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \
Expand All @@ -39,7 +45,7 @@ sudo docker build \
-f "${script_dir}/Dockerfile" \
-t qemu-virtiofs-static

sudo docker run \
sudo "${DOCKER_CLI}" run \
-i \
-v "${PWD}":/share qemu-virtiofs-static \
mv "/tmp/qemu-virtiofs-static/${qemu_virtiofs_tar}" /share/
Expand Down