mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 08:17:37 +00:00
nemu: enable compile nemu for arm64 on x86 host
This patch enable compile nemu for arm64 in container on x86 host. fixed: #577 Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
This commit is contained in:
parent
b25f6caf85
commit
17512dc3cb
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
script_name=${0##*/}
|
script_name=${0##*/}
|
||||||
|
|
||||||
arch=$(uname -m)
|
arch="${3:-$(uname -m)}"
|
||||||
|
|
||||||
|
|
||||||
# Array of configure options.
|
# Array of configure options.
|
||||||
#
|
#
|
||||||
@ -192,6 +193,18 @@ show_array() {
|
|||||||
|
|
||||||
generate_qemu_options() {
|
generate_qemu_options() {
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
|
#check if cross-compile is needed
|
||||||
|
host=$(uname -m)
|
||||||
|
if [ $arch != $host ];then
|
||||||
|
case $arch in
|
||||||
|
aarch64) qemu_options+=(size:--cross-prefix=aarch64-linux-gnu-);;
|
||||||
|
ppc64le) qemu_options+=(size:--cross-prefix=powerpc64le-linux-gnu-);;
|
||||||
|
s390x) exit;;
|
||||||
|
x86_64);;
|
||||||
|
*) exit;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# Disabled options
|
# Disabled options
|
||||||
|
|
||||||
# bluetooth support not required
|
# bluetooth support not required
|
||||||
@ -252,7 +265,9 @@ generate_qemu_options() {
|
|||||||
|
|
||||||
# Disable TCG support
|
# Disable TCG support
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
aarch64) ;;
|
aarch64)
|
||||||
|
echo $hypervisor | grep -q nemu && qemu_options+=(size:--disable-tcg)
|
||||||
|
;;
|
||||||
x86_64) qemu_options+=(size:--disable-tcg) ;;
|
x86_64) qemu_options+=(size:--disable-tcg) ;;
|
||||||
ppc64le) ;;
|
ppc64le) ;;
|
||||||
s390x) qemu_options+=(size:--disable-tcg) ;;
|
s390x) qemu_options+=(size:--disable-tcg) ;;
|
||||||
|
70
static-build/nemu/Dockerfile_cross
Normal file
70
static-build/nemu/Dockerfile_cross
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# Copyright (c) 2019 ARM Limited
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
FROM debian
|
||||||
|
|
||||||
|
ARG NEMU_REPO
|
||||||
|
ARG NEMU_VERSION
|
||||||
|
ARG NEMU_OVMF
|
||||||
|
ARG VIRTIOFSD_RELEASE
|
||||||
|
ARG VIRTIOFSD
|
||||||
|
ARG PREFIX
|
||||||
|
ARG GEN_ARCH
|
||||||
|
ARG DPKG_ARCH
|
||||||
|
|
||||||
|
WORKDIR /root/nemu
|
||||||
|
|
||||||
|
RUN echo "deb http://deb.debian.org/debian stable main" > /etc/apt/sources.list
|
||||||
|
RUN echo "deb http://deb.debian.org/debian stable-updates main" >> /etc/apt/sources.list
|
||||||
|
RUN echo "deb http://security.debian.org stable/updates main" >> /etc/apt/sources.list
|
||||||
|
RUN dpkg --add-architecture $DPKG_ARCH
|
||||||
|
|
||||||
|
RUN apt update && apt install -y \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
bc \
|
||||||
|
bison \
|
||||||
|
cpio \
|
||||||
|
curl \
|
||||||
|
flex \
|
||||||
|
gawk \
|
||||||
|
git \
|
||||||
|
make \
|
||||||
|
pkg-config \
|
||||||
|
python \
|
||||||
|
python-dev \
|
||||||
|
rsync \
|
||||||
|
gcc-$GEN_ARCH-linux-gnu \
|
||||||
|
libaudit-dev:$DPKG_ARCH \
|
||||||
|
libcap-dev:$DPKG_ARCH \
|
||||||
|
libcap-ng-dev:$DPKG_ARCH \
|
||||||
|
libdw-dev:$DPKG_ARCH \
|
||||||
|
libelf-dev:$DPKG_ARCH \
|
||||||
|
libglib2.0-0:$DPKG_ARCH \
|
||||||
|
libglib2.0-dev:$DPKG_ARCH \
|
||||||
|
zlib1g-dev:$DPKG_ARCH \
|
||||||
|
librbd-dev:$DPKG_ARCH \
|
||||||
|
libltdl-dev:$DPKG_ARCH \
|
||||||
|
libpixman-1-dev:$DPKG_ARCH
|
||||||
|
|
||||||
|
RUN cd .. && git clone --depth=1 "${NEMU_REPO}" nemu
|
||||||
|
RUN git fetch origin --tags && 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 curl -O http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-defaults/pkg-config-"${GEN_ARCH}"-linux-gnu_7.4.0-1ubuntu2.3_amd64.deb && dpkg -i pkg*
|
||||||
|
|
||||||
|
ENV PKG_CONFIG_PATH $PKG_CONFIG_PATH:/usr/lib/"${GEN_ARCH}"-linux-gnu/pkgconfig/:/usr/"${GEN_ARCH}"-linux-gnu/lib/pkgconfig
|
||||||
|
RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-nemu ${GEN_ARCH} | xargs ./configure \
|
||||||
|
--with-pkgversion=kata-static
|
||||||
|
RUN make -j$($(nproc)-1) CONFIG_HID_DEV=y
|
||||||
|
RUN make install DESTDIR=/tmp/nemu-static
|
||||||
|
|
||||||
|
RUN curl -O "${NEMU_OVMF}" && mv OVMF.fd /tmp/nemu-static/"${PREFIX}"/share/kata-nemu/
|
||||||
|
RUN mv /tmp/nemu-static/"${PREFIX}"/bin/qemu-system-$GEN_ARCH /tmp/nemu-static/"${PREFIX}"/bin/nemu-system-$GEN_ARCH
|
||||||
|
RUN curl -O "${VIRTIOFSD_RELEASE}/${VIRTIOFSD}" && chmod +x ${VIRTIOFSD} && mv ${VIRTIOFSD} /tmp/nemu-static/"${PREFIX}"/bin/
|
||||||
|
|
||||||
|
RUN cd /tmp/nemu-static && tar -czvf kata-nemu-static.tar.gz *
|
||||||
|
|
@ -7,7 +7,7 @@ MK_DIR :=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|||||||
CONFIG_DIR := $(MK_DIR)/../../scripts/
|
CONFIG_DIR := $(MK_DIR)/../../scripts/
|
||||||
|
|
||||||
build:
|
build:
|
||||||
"$(MK_DIR)/build-static-nemu.sh"
|
"$(MK_DIR)/build-static-nemu.sh" $(arch)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f kata-nemu-static.tar.gz
|
rm -f kata-nemu-static.tar.gz
|
||||||
|
@ -15,6 +15,30 @@ source "${script_dir}/../../scripts/lib.sh"
|
|||||||
config_dir="${script_dir}/../../scripts/"
|
config_dir="${script_dir}/../../scripts/"
|
||||||
nemu_tar="kata-nemu-static.tar.gz"
|
nemu_tar="kata-nemu-static.tar.gz"
|
||||||
|
|
||||||
|
if [ $# -ne 0 ];then
|
||||||
|
arch="$1"
|
||||||
|
case "$arch" in
|
||||||
|
aarch64) dpkg_arch="arm64"
|
||||||
|
Dockerfile="Dockerfile_cross"
|
||||||
|
;;
|
||||||
|
ppc64le) arch="powerpc64le"
|
||||||
|
dpkg_arch="ppc64el"
|
||||||
|
Dockerfile="Dockerfile_cross"
|
||||||
|
;;
|
||||||
|
s390x) dpkg_arch=$arch
|
||||||
|
Dockerfile="Dockerfile_cross"
|
||||||
|
;;
|
||||||
|
x86_64) dpkg_arch="amd64"
|
||||||
|
$arch="amd64"
|
||||||
|
Dockerfile="Dockerfile"
|
||||||
|
;;
|
||||||
|
*) die "$arch is not support for cross compile" ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
arch=""
|
||||||
|
dpkg_arch=""
|
||||||
|
fi
|
||||||
|
|
||||||
nemu_repo="${nemu_repo:-}"
|
nemu_repo="${nemu_repo:-}"
|
||||||
nemu_version="${nemu_version:-}"
|
nemu_version="${nemu_version:-}"
|
||||||
nemu_ovmf_repo="${nemu_ovmf_repo:-}"
|
nemu_ovmf_repo="${nemu_ovmf_repo:-}"
|
||||||
@ -58,8 +82,10 @@ sudo docker build \
|
|||||||
--build-arg VIRTIOFSD_RELEASE="${nemu_virtiofsd_release}" \
|
--build-arg VIRTIOFSD_RELEASE="${nemu_virtiofsd_release}" \
|
||||||
--build-arg VIRTIOFSD="${nemu_virtiofsd_binary}" \
|
--build-arg VIRTIOFSD="${nemu_virtiofsd_binary}" \
|
||||||
--build-arg PREFIX="${prefix}" \
|
--build-arg PREFIX="${prefix}" \
|
||||||
|
--build-arg DPKG_ARCH="${dpkg_arch}" \
|
||||||
|
--build-arg GEN_ARCH="${arch}" \
|
||||||
"${config_dir}" \
|
"${config_dir}" \
|
||||||
-f "${script_dir}/Dockerfile" \
|
-f "${script_dir}/$Dockerfile" \
|
||||||
-t nemu-static
|
-t nemu-static
|
||||||
|
|
||||||
sudo docker run \
|
sudo docker run \
|
||||||
|
Loading…
Reference in New Issue
Block a user