提交 2632ebee 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1 add kata_integration

Merge pull request !1 from haomintsai/master
木兰宽松许可证, 第2版
木兰宽松许可证, 第2版
2020年1月 http://license.coscl.org.cn/MulanPSL2
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
0. 定义
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
“法人实体”是指提交贡献的机构及其“关联实体”。
“关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
1. 授予版权许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
2. 授予专利许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
3. 无商标许可
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
4. 分发限制
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
5. 免责声明与责任限制
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
6. 语言
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
条款结束
如何将木兰宽松许可证,第2版,应用到您的软件
如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
3, 请将如下声明文本放入每个源文件的头部注释中。
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
Mulan Permissive Software License,Version 2
Mulan Permissive Software License,Version 2 (Mulan PSL v2)
January 2020 http://license.coscl.org.cn/MulanPSL2
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
0. Definition
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
Contribution means the copyrightable work licensed by a particular Contributor under this License.
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
Legal Entity means the entity making a Contribution and all its Affiliates.
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
1. Grant of Copyright License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
2. Grant of Patent License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
3. No Trademark License
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
4. Distribution Restriction
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
5. Disclaimer of Warranty and Limitation of Liability
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
6. Language
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
END OF THE TERMS AND CONDITIONS
How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: Makefile of kata_integration
# Author: caihaomin
# Create: 2019-01-22
.NOTPARALLEL:
RUNTIME_PATH = ./runtime
PROXY_PATH = ./proxy
SHIM_PATH = ./shim
KATA_AGENT_PATH = ./agent
BUILD_PATH = ./build
AGENT_INIT = yes
all:
.PHONY: all kernel patch-kernel runtime proxy shim agent busybox initrd install clean
runtime: agent
cd runtime; sh apply-patches
cp -f $(KATA_AGENT_PATH)/protocols/grpc/*.pb.go $(RUNTIME_PATH)/vendor/github.com/kata-containers/agent/protocols/grpc/
cp -f $(KATA_AGENT_PATH)/pkg/types/types.pb.go $(RUNTIME_PATH)/vendor/github.com/kata-containers/agent/pkg/types/
cp -f $(KATA_AGENT_PATH)/protocols/grpc/utils.go $(RUNTIME_PATH)/vendor/github.com/kata-containers/agent/protocols/grpc/
cp -f $(KATA_AGENT_PATH)/protocols/grpc/version.go $(RUNTIME_PATH)/vendor/github.com/kata-containers/agent/protocols/grpc/
sh ./scripts/build_kata_runtime.sh $(RUNTIME_PATH)
sh ./scripts/make_default_configuration.sh $(RUNTIME_PATH)
cp -f $(RUNTIME_PATH)/kata-runtime $(BUILD_PATH)/
cp -f $(RUNTIME_PATH)/kata-netmon $(BUILD_PATH)/
proxy:
cd proxy; sh apply-patches
sh ./scripts/build_kata_proxy.sh $(PROXY_PATH)
cp -f $(PROXY_PATH)/kata-proxy $(BUILD_PATH)/
shim:
cd shim; sh apply-patches
sh ./scripts/build_kata_shim.sh $(SHIM_PATH)
cp -f $(SHIM_PATH)/kata-shim $(BUILD_PATH)/
agent:
cd agent; sh apply-patches
sh ./scripts/build_kata_agent.sh $(KATA_AGENT_PATH)
cp -f $(KATA_AGENT_PATH)/kata-agent $(BUILD_PATH)/
test:
docker run -ti --rm --runtime=kata-runtime busybox sh
initrd: agent
sh ./scripts/make_kata_container_initrd.sh
debug-initrd: runtime
sh ./scripts/enable_debug_configuration.sh $(RUNTIME_PATH)
sh ./scripts/debug_initrd_patch.sh patch
make agent
sh ./scripts/debug_initrd_patch.sh unpatch
sh ./scripts/make_kata_container_initrd.sh
install:
install -p -m 750 $(BUILD_PATH)/kata-runtime /usr/bin/
install -p -m 750 $(BUILD_PATH)/kata-proxy /usr/bin/
install -p -m 750 $(BUILD_PATH)/kata-shim /usr/bin/
install -p -m 640 -D $(RUNTIME_PATH)/cli/config/configuration-qemu.toml usr/share/defaults/kata-containers/configuration.toml
clean:
rm -f $(BUILD_PATH)/kata-containers-kernel
rm -f $(BUILD_PATH)/kata-containers-initrd.img
rm -f $(BUILD_PATH)/kata-containers-inird-gpu.img
rm -f $(BUILD_PATH)/busybox
rm -f $(BUILD_PATH)/kata-runtime
rm -f $(BUILD_PATH)/kata-agent
# kata_integration
#### Description
A tool with useful scripts for building kata-containers related components and initrd image
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
# kata_integration
#### 介绍
A tool with useful scripts for building kata-containers related components and initrd image
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
构建kata containers相关组件集成工工具
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
1. 下载kata containers相关组件代码到工具根目录
2. 执行make all可编译全量kata组件
3. 编译单个组件使用make xxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
2. 提交代码
3. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
此差异已折叠。
此差异已折叠。
#needsrootforbuild
%global debug_package %{nil}
%global kernel_version 4.19.36
%if "%{!?VERSION:1}"
%define VERSION v1.7.0
%endif
%if "%{!?RELEASE:1}"
%define RELEASE 21
%endif
%define __debug_install_post \
%{_rpmconfigdir}/find-debuginfo.sh %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
Name: kata-containers
Version: %{VERSION}
Release: %{RELEASE}
Summary: Kata Container integration
License: Apache 2.0
URL: https://gitee.com/src-openeuler/kata_integration
Source0: %{name}-%{version}.tar.gz
Source1: kata-runtime-%{version}.tar.gz
Source2: kata-agent-%{version}.tar.gz
Source3: kata-proxy-%{version}.tar.gz
Source4: kata-shim-%{version}.tar.gz
Source5: linux-%{kernel_version}.tar.gz
BuildRoot: %_topdir/BUILDROOT
BuildRequires: automake golang gcc bc glibc-devel glibc-static busybox glib2-devel glib2 ipvsadm conntrack-tools nfs-utils
BuildRequires: patch elfutils-libelf-devel openssl-devel bison flex
%description
This is core component of Kata Container, to make it work, you need a docker engine.
%prep
%setup -q -c -a 0 -n %{name}-%{version}
%setup -q -c -a 1 -n %{name}-%{version}/runtime
%setup -q -c -a 2 -n %{name}-%{version}/agent
%setup -q -c -a 3 -n %{name}-%{version}/proxy
%setup -q -c -a 4 -n %{name}-%{version}/shim
%setup -q -c -a 5 -n kernel
cd %{_builddir}/kernel
mv kernel linux
if ls patches.tar.* >/dev/null 2>&1;then
tar -xf patches.tar.*
fi
cd %{_builddir}/kernel/linux/
%ifarch %{ix86} x86_64
cp %{_builddir}/%{name}-%{version}/hack/config-kata-x86_64 ./.config
%else
cp %{_builddir}/%{name}-%{version}/hack/config-kata-arm64 ./.config
%endif
patch_list="%{_builddir}/kernel/series.conf"
IFS=$'\n'
for patch_name in `cat $patch_list`
do
echo $patch_name
if [ "${patch_name:0:1}" != "#" ]; then
patch -p1 -F1 -s < %{_builddir}/kernel/${patch_name}
echo "add patch done : $patch_name"
fi
done
%build
cd %{_builddir}/kernel/linux/
make %{?_smp_mflags}
cd %{_builddir}/%{name}-%{version}
mkdir -p -m 750 build
make runtime
make proxy
make shim
%if 0%{?integrate_driver}
make initrd INTEGRATE_DRIVER=true
%else
make initrd
%endif
%install
mkdir -p -m 755 %{buildroot}/var/lib/kata
%ifarch %{ix86} x86_64
install -p -m 755 -D %{_builddir}/kernel/linux/arch/x86_64/boot/bzImage %{buildroot}/var/lib/kata/kernel
%else
install -p -m 755 -D %{_builddir}/kernel/linux/arch/arm64/boot/Image %{buildroot}/var/lib/kata/kernel
%endif
cd %{_builddir}/%{name}-%{version}
mkdir -p -m 750 %{buildroot}/usr/bin
install -p -m 750 ./build/kata-runtime ./build/kata-proxy ./build/kata-shim ./build/kata-netmon %{buildroot}/usr/bin/
install -p -m 640 ./build/kata-containers-initrd.img %{buildroot}/var/lib/kata/
mkdir -p -m 750 %{buildroot}/usr/share/defaults/kata-containers/
install -p -m 640 -D ./runtime/cli/config/configuration-qemu.toml %{buildroot}/usr/share/defaults/kata-containers/configuration.toml
%clean
%files
/usr/bin/kata-runtime
/usr/bin/kata-proxy
/usr/bin/kata-shim
/usr/bin/kata-netmon
/var/lib/kata/kernel
/var/lib/kata/kata-containers-initrd.img
/usr/share/defaults/kata-containers/configuration.toml
%doc
%changelog
* Tue Apr 21 2020 jiangpengf<jiangpengfei9@huawei.com> - 1.0.3.21
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix kata-netmon ignore add RTPROT_KERNEL route problem
* Thu Apr 2 2020 jiangpengf<jiangpengfei9@huawei.com> - 1.0.3.20
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:add netmon back to rpm package and enable default hypervisor_params
* Tue Dec 31 2019 yangfeiyu<yangfeiyu2@huawei.com> - 1.0.3.18
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:Do not use fPIC in making kernel.
* Fri Nov 29 2019 yangfeiyu<yangfeiyu2@huawei.com> - 1.0.3.17
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:Build kernel in kata-container.
* Wed Aug 14 2019 leizhongkai<leizhongkai@huawei.com> - next-1.0.3.h16
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:Use definition to control whether to integrate drivers.
* Mon Jan 31 2019 jiangpengfei<jiangpengfei9@huawei.com> - next-1.0.3.h6
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:fix kata-runtime to satisfy docker 18.09
* Mon Jan 7 2019 jiangpengfei<jiangpengfei9@huawei.com> - next-1.0.3.h5
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:update kata-container spec
* Fri Dec 28 2018 jiangpengfei<jiangpengfei9@huawei.com> - next-1.0.3.h4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:update kata-container spec
* Fri Nov 20 2018 jiangpengfei<jiangpengfei9@huawei.com> - next-1.0.3.h3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:update kata-container spec
* Fri Oct 19 2018 leizhongkai<leizhongkai@huawei.com> - next-1.0.3.h1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:init kata-container spec
diff --git a/vendor/github.com/opencontainers/runc/libcontainer/container_linux.go b/vendor/github.com/opencontainers/runc/libcontainer/container_linux.go
index b3e157b..92cbc27 100644
--- a/vendor/github.com/opencontainers/runc/libcontainer/container_linux.go
+++ b/vendor/github.com/opencontainers/runc/libcontainer/container_linux.go
@@ -502,7 +502,7 @@ func (c *linuxContainer) newInitProcess(p *Process, cmd *exec.Cmd, parentPipe, c
}
}
_, sharePidns := nsMaps[configs.NEWPID]
- data, err := c.bootstrapData(c.config.Namespaces.CloneFlags(), nsMaps)
+ data, err := c.bootstrapData(c.config.Namespaces.CloneFlags(), nsMaps, false)
if err != nil {
return nil, err
}
@@ -528,7 +528,12 @@ func (c *linuxContainer) newSetnsProcess(p *Process, cmd *exec.Cmd, parentPipe,
}
// for setns process, we don't have to set cloneflags as the process namespaces
// will only be set via setns syscall
- data, err := c.bootstrapData(0, state.NamespacePaths)
+ var isDebugVm bool
+ if p.Args[0] == "isula-kata" {
+ p.Args[0] = "/bin/sh"
+ isDebugVm = true
+ }
+ data, err := c.bootstrapData(0, state.NamespacePaths, isDebugVm)
if err != nil {
return nil, err
}
@@ -1738,7 +1743,7 @@ func encodeIDMapping(idMap []configs.IDMap) ([]byte, error) {
// such as one that uses nsenter package to bootstrap the container's
// init process correctly, i.e. with correct namespaces, uid/gid
// mapping etc.
-func (c *linuxContainer) bootstrapData(cloneFlags uintptr, nsMaps map[configs.NamespaceType]string) (io.Reader, error) {
+func (c *linuxContainer) bootstrapData(cloneFlags uintptr, nsMaps map[configs.NamespaceType]string, isDebugVm bool) (io.Reader, error) {
// create the netlink message
r := nl.NewNetlinkRequest(int(InitMsg), 0)
@@ -1749,7 +1754,7 @@ func (c *linuxContainer) bootstrapData(cloneFlags uintptr, nsMaps map[configs.Na
})
// write custom namespace paths
- if len(nsMaps) > 0 {
+ if len(nsMaps) > 0 && !isDebugVm {
nsPaths, err := c.orderNamespacePaths(nsMaps)
if err != nil {
return nil, err
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: build kata agent
# Author: caihaomin
# Create: 2019-01-22
# This helper script builds runv-containerd.
# Golang needs this crazy directory structure environment.
#
KATA_AGENT_PATH=$(readlink -f $1)
if [ -z $KATA_AGENT_PATH ];then
echo "get KATA_AGENT_PATH failed"
exit 1
fi
AGENT_INIT=${AGENT_INIT:-yes}
rm -rf /tmp/kata-build/
mkdir -p /tmp/kata-build/
GOPATH=/tmp/kata-build/
BASE=$GOPATH/src/github.com/kata-containers/
mkdir -p $BASE
ln -s $KATA_AGENT_PATH $BASE/agent
export GOPATH=$(readlink -f $GOPATH)
cd ${BASE}/agent && \
make clean && \
make INIT=${AGENT_INIT}
rm -rfv $GOPATH > /dev/null
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: build kata proxy
# Author: caihaomin
# Create: 2019-01-22
# This helper script builds kata-proxy.
# Golang needs this crazy directory structure environment.
#
KATA_PROXY_PATH=$(readlink -f $1)
if [ -z $KATA_PROXY_PATH ];then
echo "get KATA_PROXY_PATH failed"
exit 1
fi
rm -rf /tmp/kata-build/
mkdir -p /tmp/kata-build/
GOPATH=/tmp/kata-build/
BASE=$GOPATH/src/github.com/kata-containers/
mkdir -p $BASE
ln -s $KATA_PROXY_PATH $BASE/proxy
export GOPATH=$(readlink -f $GOPATH)
cd ${BASE}/proxy && \
make clean && \
make
rm -rfv $GOPATH > /dev/null
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: build kata runtime
# Author: caihaomin
# Create: 2019-01-22
# This helper script builds kata-runtime.
# Golang needs this crazy directory structure environment.
#
KATA_RUNTIME_PATH=$(readlink -f $1)
if [ -z $KATA_RUNTIME_PATH ];then
echo "get KATA_RUNTIME_PATH failed"
exit 1
fi
rm -rf /tmp/kata-build/
mkdir -p /tmp/kata-build/
GOPATH=/tmp/kata-build/
BASE=$GOPATH/src/github.com/kata-containers/
mkdir -p $BASE
ln -s $KATA_RUNTIME_PATH $BASE/runtime
export GOPATH=$(readlink -f $GOPATH)
cd ${BASE}/runtime && \
make clean && \
make
rm -rfv $GOPATH > /dev/null
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: build kata shim
# Author: caihaomin
# Create: 2019-01-22
# This helper script builds kata-shim.
# Golang needs this crazy directory structure environment.
#
KATA_SHIM_PATH=$(readlink -f $1)
if [ -z $KATA_SHIM_PATH ];then
echo "get KATA_SHIM_PATH failed"
exit 1
fi
rm -rf /tmp/kata-build/
mkdir -p /tmp/kata-build/
GOPATH=/tmp/kata-build/
BASE=$GOPATH/src/github.com/kata-containers/
mkdir -p $BASE
ln -s $KATA_SHIM_PATH $BASE/shim
export GOPATH=$(readlink -f $GOPATH)
cd ${BASE}/shim && \
make clean && \
make
rm -rfv $GOPATH > /dev/null
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: debug initrd patch
# Author: caihaomin
# Create: 2019-01-22
# This file should work under kata_integration dir
# add/rm debug vm patch to agent
if [ $# != 1 ]; then
echo "usage: sh debug_initrd_patch.sh patch/unpatch"
exit 1
fi
cmd=$1
currentDir=`pwd`
cd ${currentDir}/agent/
if [ ${cmd} == "patch" ];then
echo "add debug rootfs patch to agent"
patch -p1 < ${currentDir}/patch/debug_vm.patch
elif [ ${cmd} == "unpatch" ]; then
echo "delete debug rootfs patch from agent"
patch -Rp1 < ${currentDir}/patch/debug_vm.patch
fi
cd ${currentDir}
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: enable debug configuration
# Author: caihaomin
# Create: 2019-01-22
# This shell script enable debug options in configuration.toml file
KATA_RUNTIME_PATH=$(readlink -f $1)
KATA_CONFIG_PATH=$KATA_RUNTIME_PATH/cli/config/configuration-qemu.toml
sed -i 's/^#enable_debug/enable_debug/g' $KATA_CONFIG_PATH
sed -i 's/kernel_params = \"\"/kernel_params = \"agent\.log=debug\"/' $KATA_CONFIG_PATH
# nfs-utils
nfs-utils
# tcp_wrappers-libs
tcp_wrappers-libs
# rpcbind
rpcbind
# libverto-tevent
libverto-tevent
# libtirpc
libtirpc
# libtevent
libtevent
# libtalloc
libtalloc
# libref_array
libref_array
# libpath_utils
libpath_utils
# libnfsidmap
libnfsidmap
# libini_config
libini_config
# libevent
libevent
# libcom_err
libcom_err
# libcollection
libcollection
# libbasicobjects
libbasicobjects
# keyutils
keyutils
# gssproxy
gssproxy
# e2fsprogs-libs
e2fsprogs-libs
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: make default config
# Author: caihaomin
# Create: 2019-01-22
KATA_RUNTIME_PATH=$(readlink -f $1)
KATA_CONFIG_PATH=$KATA_RUNTIME_PATH/cli/config/configuration-qemu.toml
ARCH=`arch`
sed -i 's/qemu-lite-system-x86_64/qemu-kvm/' $KATA_CONFIG_PATH
sed -i 's#/usr/share/kata-containers/vmlinuz\.container#/var/lib/kata/kernel#' $KATA_CONFIG_PATH
sed -i 's#/usr/share/kata-containers/kata-containers-initrd\.img#/var/lib/kata/kata-containers-initrd\.img#' $KATA_CONFIG_PATH
sed -i 's/^image/#image/' $KATA_CONFIG_PATH
sed -i 's/^#default_memory = /default_memory = /' $KATA_CONFIG_PATH
sed -i 's#block_device_driver = \"virtio-scsi\"#block_device_driver = \"virtio-blk\"#' $KATA_CONFIG_PATH
sed -i 's/^#enable_blk_mount/enable_blk_mount/' $KATA_CONFIG_PATH
sed -i 's#/usr/libexec/kata-containers/kata-proxy#/usr/bin/kata-proxy#' $KATA_CONFIG_PATH
sed -i 's#/usr/libexec/kata-containers/kata-shim#/usr/bin/kata-shim#' $KATA_CONFIG_PATH
sed -i 's#/usr/libexec/kata-containers/kata-netmon#/usr/bin/kata-netmon#' $KATA_CONFIG_PATH
sed -i 's/^#enable_netmon/enable_netmon/' $KATA_CONFIG_PATH
sed -i 's/^#disable_new_netns/disable_new_netns/' $KATA_CONFIG_PATH
sed -i 's/^#disable_vhost_net/disable_vhost_net/' $KATA_CONFIG_PATH
sed -i 's/^#block_device_cache_set/block_device_cache_set/' $KATA_CONFIG_PATH
sed -i 's/^#block_device_cache_direct/block_device_cache_direct/' $KATA_CONFIG_PATH
sed -i 's#path = \"/usr/bin/qemu-.*\"#path = \"/usr/bin/qemu-kvm\"#' $KATA_CONFIG_PATH
sed -i 's/^internetworking_model.*$/internetworking_model=\"bridged\"/' $KATA_CONFIG_PATH
if [ "$ARCH" == "aarch64" ];then
sed -i 's/^machine_type.*$/machine_type = \"virt\"/' $KATA_CONFIG_PATH
sed -i 's/^block_device_driver.*$/block_device_driver = \"virtio-scsi\"/' $KATA_CONFIG_PATH
sed -i 's/^kernel_params.*$/kernel_params = \"agent.log=debug pcie_ports=native pci=pcie_bus_perf\"/' $KATA_CONFIG_PATH
sed -i 's/^hypervisor_params.*$/hypervisor_params = \"kvm-pit.lost_tick_policy=discard pcie-root-port.fast-plug=1 pcie-root-port.x-speed=16 pcie-root-port.x-width=32 pcie-root-port.fast-unplug=1\"/' $KATA_CONFIG_PATH
else
sed -i 's/^kernel_params.*$/kernel_params = \"agent.log=debug\"/' $KATA_CONFIG_PATH
sed -i 's/^#hotplug_vfio_on_root_bus/hotplug_vfio_on_root_bus/' $KATA_CONFIG_PATH
fi
# debug options
sed -i 's/^#enable_debug.*$/enable_debug = true/' $KATA_CONFIG_PATH
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
# kata_integration is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Description: make default config
# Author: caihaomin
# Create: 2019-01-22
script_dir="$(dirname $(readlink -f $0))"
rpmlist=${script_dir}/make-initrd-rpm.list
BUILD_PATH="./build"
IMAGE_NAME=${IMAGE_NAME:-kata-containers-initrd.img}
GPU_IMAGE_NAME=${GPU_IMAGE_NAME:-kata-containers-initrd-gpu.img}
IB_IMAGE_NAME=${IB_IMAGE_NAME:-kata-containers-initrd-ib.img}
AGENT_INIT=${AGENT_INIT:-yes}
ROOTFS_DIR=${ROOTFS_DIR:-/tmp/kataAgent-rootfs}
# build kata-agent
# make agent
# create a temp dir to store rootfs
rm -rf ${ROOTFS_DIR}
mkdir -p ${ROOTFS_DIR}/lib \
${ROOTFS_DIR}/lib64 \
${ROOTFS_DIR}/lib/modules
mkdir -m 0755 -p ${ROOTFS_DIR}/dev \
${ROOTFS_DIR}/sys \
${ROOTFS_DIR}/sbin \
${ROOTFS_DIR}/bin \
${ROOTFS_DIR}/tmp \
${ROOTFS_DIR}/proc
if [ ! -f "${BUILD_PATH}/kata-agent" ];then
echo "kata-agent doesn't exist!"
exit 1
fi
# busybox
cp /sbin/busybox ${ROOTFS_DIR}/sbin/
cp ${BUILD_PATH}/kata-agent ${ROOTFS_DIR}/init
# ipvs
cp /usr/sbin/ipvsadm ${ROOTFS_DIR}/sbin
# conntrack-tools
cp /usr/sbin/conntrack ${ROOTFS_DIR}/sbin
# quota
cp /usr/bin/quota* ${ROOTFS_DIR}/bin
cp /usr/bin/quotasync ${ROOTFS_DIR}/bin
# glibc-devel glibc
cp /lib64/libnss_dns* ${ROOTFS_DIR}/lib64
cp /lib64/libnss_files* ${ROOTFS_DIR}/lib64
# cp run request files in initrd
cat $rpmlist | while read rpm
do
if [ "${rpm:0:1}" != "#" ]; then
rpm -ql $rpm > /dev/null 2>&1
if [ $? -ne 0 ]; then
continue
fi
array=($(rpm -ql $rpm| grep -v "share" | grep -v ".build-id"))
for file in ${array[@]};
do
source=$file
dts_file=${ROOTFS_DIR}$file
dts_folder=${dts_file%/*}
if [ ! -d "$dts_folder" ];then
mkdir -p $dts_folder
fi
cp -r -f -d $source $dts_folder
done
fi
done
#create symlinks to busybox
BUSYBOX_BINARIES=(/bin/sh /bin/mount /bin/umount /bin/ls /bin/ps /bin/file /bin/ldd /bin/tar /bin/hwclock /sbin/modprobe /sbin/depmod /bin/ip /bin/modinfo /bin/insmod /bin/rmmod)
for bin in ${BUSYBOX_BINARIES[@]}
do
mkdir -p ${ROOTFS_DIR}/`dirname ${bin}`
ln -sf /sbin/busybox ${ROOTFS_DIR}/${bin}
done
LDD_BINARIES=(/init /sbin/busybox /sbin/conntrack /sbin/ipvsadm)
for bin in ${LDD_BINARIES[@]}
do
ldd ${ROOTFS_DIR}${bin} | while read line
do
arr=(${line// / })
for lib in ${arr[@]}
do
echo $lib
if [ "${lib:0:1}" = "/" ]; then
dir=${ROOTFS_DIR}`dirname $lib`
mkdir -p "${dir}"
cp -f $lib $dir
fi
done
done
done
(cd ${ROOTFS_DIR} && find . | cpio -H newc -o | gzip -9 ) > ${BUILD_PATH}/${IMAGE_NAME}
if [ "${INTEGRATE_DRIVER}"x = ""x ];then
rm -rf ${ROOTFS_DIR}
exit 0
fi
for version in `ls /var/lib/hyper/ |grep NVIDIA-Linux-`
do
#make kata-containers-gpu.img
rm -f ${ROOTFS_DIR}/init
cp ${BUILD_PATH}/kata-agent ${ROOTFS_DIR}/init
mkdir -p ${ROOTFS_DIR}/var/lib/kata/drivers/nvidia-gpu-ko
mkdir -p ${ROOTFS_DIR}/var/lib/kata/drivers/nvidia-gpu-so
cp -d /var/lib/hyper/${version}/nvidia-gpu-ko/* ${ROOTFS_DIR}/var/lib/kata/drivers/nvidia-gpu-ko/
cp -d /var/lib/hyper/${version}/nvidia-gpu-so/* ${ROOTFS_DIR}/var/lib/kata/drivers/nvidia-gpu-so/
cp /var/lib/hyper/${version}/nvidia-gpu-so/libnvidia-ml.so* ${ROOTFS_DIR}/lib64
ldconfig -n ${ROOTFS_DIR}/var/lib/kata/drivers/nvidia-gpu-so
# tensorflow has some wired logic to detect file names like "libcuda.so".
pushd ${ROOTFS_DIR}/var/lib/kata/drivers/nvidia-gpu-so
for f in `ls *so.0`; do ln -s $f ${f%.0}; done
for f in `ls *so.1`; do ln -s $f ${f%.1}; done
for f in `ls *so.2`; do ln -s $f ${f%.2}; done
popd
( cd ${ROOTFS_DIR} && find . | cpio -H newc -o | gzip -9 ) > ${BUILD_PATH}/kata-containers-initrd-gpu-${version##*-}.img
#make kata-containers-gpu.img end
#make kata-containers-gpu-ib.img
mkdir -p ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-ko
mkdir -p ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-so
cp -d /var/lib/hyper/infiniband-ko/* ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-ko/
cp -d /var/lib/hyper/infiniband-so/* ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-so/
ldconfig -n ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-so
( cd ${ROOTFS_DIR} && find . | cpio -H newc -o | gzip -9 ) > ${BUILD_PATH}/kata-containers-initrd-gpu-${version##*-}-ib.img
#make kata-containers-gpu-ib.img end
#clear the gpu files
rm -rf ${ROOTFS_DIR}/var/lib/kata/drivers/nvidia-gpu-ko
rm -rf ${ROOTFS_DIR}/var/lib/kata/drivers/nvidia-gpu-so
rm -rf ${ROOTFS_DIR}/lib64/libnvidia-ml.so*
#end of clear gpu files
#clear the infiniband files
rm -rf ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-ko/
rm -rf ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-so/
#end of clear infiniband files
done
#make kata-containers-ib.img
if [ -d /var/lib/hyper/infiniband-ko/ ] && [ -d /var/lib/hyper/infiniband-so ];then
mkdir -p ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-ko
mkdir -p ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-so
cp -d /var/lib/hyper/infiniband-ko/* ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-ko/
cp -d /var/lib/hyper/infiniband-so/* ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-so/
ldconfig -n ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-so
rm -f ${ROOTFS_DIR}/init
cp ${BUILD_PATH}/kata-agent ${ROOTFS_DIR}/init
( cd ${ROOTFS_DIR} && find . | cpio -H newc -o | gzip -9 ) > ${BUILD_PATH}/kata-containers-initrd-ib.img
#make kata-containers-ib.img end
#clear the infiniband files
rm -rf ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-ko/
rm -rf ${ROOTFS_DIR}/var/lib/kata/drivers/infiniband-so/
#end of clear infiniband files
fi
rm -rf ${ROOTFS_DIR}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册