转换LFS仓库为普通仓库

This commit is contained in:
Jiayi Yin 2025-05-18 17:30:05 +00:00
commit 3eba918bda
16 changed files with 3344 additions and 0 deletions

36
README.en.md Normal file
View File

@ -0,0 +1,36 @@
# kata-containers
#### Description
The speed of containers, the security of VMs
#### 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/)

37
README.md Normal file
View File

@ -0,0 +1,37 @@
# kata-containers
#### 介绍
The speed of containers, the security of VMs
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

21
apply-patches Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
set -e
if [[ -f ./patch_flag ]];then
echo "patched!"
exit 0
fi
tar -zxvf kata-containers-3.2.0.tar.gz
cp -rf ./kata-containers-3.2.0/* ./
cat ./series.conf | while read line
do
if [[ $line == '' || $line =~ ^\s*# ]]; then
continue
fi
echo "====patch $line======"
patch -p1 -F1 -s < ./patches/$line
done
touch ./patch_flag

Binary file not shown.

Binary file not shown.

412
kata-containers.spec Normal file
View File

@ -0,0 +1,412 @@
#needsrootforbuild
%global debug_package %{nil}
%define VERSION 3.2.0
%define RELEASE 6
Name: kata-containers
Version: %{VERSION}
Release: %{RELEASE}
Summary: Kata Container, the speed of containers, the security of VMs
License: ISC and Apache-2.0 and GPL-2.0-or-later and CC-BY-SA-4.0 and MIT and MPL-2.0
URL: https://github.com/kata-containers
Source0: kata_integration-openeuler.tar.gz
Source1: kata-containers-openeuler.tar.gz
Source2: kernel.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 rust cargo rust-packaging libgcc dtc-devel
%ifarch riscv64
BuildRequires: protobuf-compiler dwarves
%endif
%description
This is core component of Kata Container, to make it work, you need a isulad/docker engine.
%prep
%setup -T -c -a 0 -n kata_integration
%setup -T -c -a 1 -n kata-containers
%setup -T -c -a 2 -n kernel
# extract the kata_integration.tar.gz file
cd %{_builddir}/kata_integration
# apply kata_integration patches
sh apply-patches
# build kernel
cd %{_builddir}/kernel
mv kernel linux
cd %{_builddir}/kernel/linux/
%ifarch %{ix86} x86_64
cp %{_builddir}/kata_integration/hack/config-kata-x86_64 ./.config
%elifarch riscv64
cp arch/riscv/configs/openeuler_defconfig ./.config
%else
cp %{_builddir}/kata_integration/hack/config-kata-arm64 ./.config
%endif
%build
cd %{_builddir}/kernel/linux/
make olddefconfig
make %{?_smp_mflags}
cd %{_builddir}/kata-containers/
sh -x apply-patches
tar -xzf kata-containers-%{version}-vendor.tar.gz
cd %{_builddir}/kata-containers/src/runtime
make clean
make
cd %{_builddir}/kata-containers/src/agent
cp %{_builddir}/kata-containers/version.rs ./src/
cat > .cargo/config << EOF
[build]
rustflags = ["-Clink-arg=-s","-Clink-arg=-lgcc","-Clink-arg=-lfdt"]
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
EOF
/usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 cargo build --release
cd %{_builddir}/kata_integration
mkdir -p -m 750 build
cp %{_builddir}/kata-containers/src/agent/target/release/kata-agent ./build/
strip ./build/kata-agent
make initrd
%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
%elifarch riscv64
install -p -m 755 -D %{_builddir}/kernel/linux/arch/riscv/boot/Image %{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}/kata_integration
mkdir -p -m 750 %{buildroot}/usr/bin
install -p -m 750 %{_builddir}/kata-containers/src/runtime/kata-runtime %{buildroot}/usr/bin/
install -p -m 750 %{_builddir}/kata-containers/src/runtime/kata-monitor %{buildroot}/usr/bin/
install -p -m 750 %{_builddir}/kata-containers/src/runtime/containerd-shim-kata-v2 %{buildroot}/usr/bin/
install -p -m 640 -D %{_builddir}/kata-containers/src/runtime/config/configuration-qemu.toml %{buildroot}/usr/share/defaults/kata-containers/configuration.toml
%ifnarch riscv64
install -p -m 640 -D %{_builddir}/kata-containers/src/runtime/config/configuration-stratovirt.toml %{buildroot}/usr/share/defaults/kata-containers/configuration-stratovirt.toml
%endif
install -p -m 640 ./build/kata-containers-initrd.img %{buildroot}/var/lib/kata/
mkdir -p -m 750 %{buildroot}/usr/share/defaults/kata-containers/
strip %{buildroot}/usr/bin/kata*
strip %{buildroot}/usr/bin/containerd-shim-kata-v2
%clean
%files
/usr/bin/kata-runtime
/usr/bin/kata-monitor
/usr/bin/containerd-shim-kata-v2
/var/lib/kata/kernel
/var/lib/kata/kata-containers-initrd.img
%config(noreplace) /usr/share/defaults/kata-containers/configuration.toml
%ifnarch riscv64
%config(noreplace) /usr/share/defaults/kata-containers/configuration-stratovirt.toml
%endif
%doc
%changelog
* Fri Dec 27 2024 laokz <zhangkai@iscas.ac.cn> - 3.2.0-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:riscv64: fix typo
* Wed Nov 27 2024 heruoqing <heruoqing@iscas.ac.cn> - 3.2.0-5
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix missing kernel config for RISC-V when building
* Wed May 8 2024 heruoqing <ruoqing@isrc.iscas.ac.cn> - 3.2.0-4
- Type:feature
- ID:NA
- SUG:NA
- DESC:add riscv64 platform support for kata 3.2.0
* Tue May 7 2024 xuxuepeng <xuxuepeng1@huawei.com> - 3.2.0-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:allow swappiness to be -1 as default
* Tue May 7 2024 wenyuanlau <liuwenyuan9@huawei.com> - 3.2.0-2
- Type:feature
- ID:NA
- SUG:NA
- DESC:add stratovirt microvm support for kata 3.2.0
* Tue Feb 19 2024 Vanient <xidanni1@huawei.com> - 3.2.0-1
- Type:feature
- ID:NA
- SUG:NA
- DESC:update to 3.2.0
* Tue Sep 5 2023 xiadanni <xiadanni1@huawei.com> - 2.1.0-33
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:update cgroup-rs crate to fix for set_kmem_limit error
* Mon Mar 6 2023 zhukeqian <zhukeqian1@huawei.com> - 2.1.0-32
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:append readonly option when get pflash cmdline for stratovirt runtime
* Thu Mar 02 2023 Vanient<xiadanni1@huawei.com> - 2.1.0-31
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:make oldconfig to disable unuseable config
* Thu Sep 8 2022 xiadanni <xiadanni1@huawei.com> - 2.1.0-30
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:optimize compile options
* Fri Sep 2 2022 chengzeruizhi <chengzeruizhi@huawei.com> - 2.1.0-29
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:don't use props for object add
* Tue Aug 23 2022 chengzeruizhi <chengzeruizhi@huawei.com> - 2.1.0-28
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:add explicit on for kernel_irqchip
* Mon Aug 22 2022 chengzeruizhi <chengzeruizhi@huawei.com> - 2.1.0-27
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:use host device when adding block dev
* Fri Mar 18 2022 Xinle.Guo <guoxinle1@huawei.com> - 2.1.0-26
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix startup failure that adding more than 16 root port devices in stratovirt
* Wed Mar 2 2022 Xinle.Guo <guoxinle1@huawei.com> - 2.1.0-25
- Type:feature
- ID:NA
- SUG:NA
- DESC:provide a way to dynomically obtain firmware in stratovirt
* Sat Feb 26 2022 Xinle.Guo <guoxinle1@huawei.com> - 2.1.0-24
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix the problem that fails to plug net device to stratovirt
* Mon Jan 17 2022 Xinle.Guo <guoxinle1@huawei.com> - 2.1.0-23
- Type:feature
- ID:NA
- SUG:NA
- DESC:add the stratovirt standardVM sandbox type to kata container
* Thu Jan 13 2022 Xinle.Guo <guoxinle1@huawei.com> - 2.1.0-22
- Type:feature
- ID:NA
- SUG:NA
- DESC:refactor hypervisor type `stratovirt` and its methods
* Tue Jan 11 2022 Xinle.Guo <guoxinle1@huawei.com> - 2.1.0-21
- Type:feature
- ID:NA
- SUG:NA
- DESC:add stratovirt `vmConfig` struct and methods to get parameters of VM
* Mon Jan 10 2022 Xinle.Guo <guoxinle1@huawei.com> - 2.1.0-20
- Type:feature
- ID:NA
- SUG:NA
- DESC:update stratovirt configuration toml file
* Fri Dec 10 2021 yangfeiyu <yangfeiyu2@huawei.com> - 2.1.0-19
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:modify stratovirt config file
* Tue Dec 7 2021 jikui <jikui2@huawei.com> - 2.1.0-18
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix the block device not removed in devManager
* Thu Dec 2 2021 jikui <jikui2@huawei.com> - 2.1.0-17
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:don't ignore updateInterface return error
* Tue Nov 30 2021 jikui <jikui2@huawei.com> - 2.1.0-16
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:don't delete the exist tap device in the host
* Tue Nov 30 2021 jikui <jikui2@huawei.com> - 2.1.0-15
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:check VFIO when create device
* Mon Nov 29 2021 jikui <jikui2@huawei.com> - 2.1.0-14
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix delete sandbox failed problem
* Sat Nov 27 2021 jikui <jikui2@huawei.com> - 2.1.0-13
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:validate sandbox cpu and memory size
* Thu Nov 25 2021 jikui <jikui2@huawei.com> - 2.1.0-12
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:truncate the log.json file before kata-runtime subcommand executed
* Thu Nov 25 2021 jikui <jikui2@huawei.com> - 2.1.0-11
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix umount container rootfs dir return invalid argument error
* Wed Nov 24 2021 jikui <jikui2@huawei.com> - 2.1.0-10
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:increase delete cgroup retry times
* Sat Nov 20 2021 yangfeiyu <yangfeiyu2@huawei.com> - 2.1.0-9
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:modify kernel and image path in configuration.toml
* Sat Oct 16 2021 jikui <jikui2@huawei.com> - 2.1.0-8
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:keep the qemu process name same as the configured path
* Fri Oct 15 2021 jikui <jikui2@huawei.com> - 2.1.0-7
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix kata-runtime skip read lines in /proc/mounts
* Tue Oct 5 2021 jikui <jikui2@huawei.com> - 2.1.0-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix kata-runtime hungs when qemu process is D/T
* Mon Sep 27 2021 yangfeiyu <yangfeiyu2@huawei.com> - 2.1.0-5
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:chmod agent exec fifo
* Fri Sep 17 2021 yangfeiyu <yangfeiyu2@huawei.com> - 2.1.0-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:modify kata-agent build flags
* Tue Aug 24 2021 yangfeiyu <yangfeiyu2@huawei.com> - 2.1.0-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:add configuration-stratovirt.toml
* Fri Aug 20 2021 yangfeiyu <yangfeiyu2@huawei.com> - 2.1.0-2
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:support with stratovirt and isulad
* Wed Aug 18 2021 yangfeiyu <yangfeiyu2@huawei.com> - 2.1.0-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:upgrade kata-containers
* Fri Feb 19 2021 xinghe <xinghe1@huawei.com> - 1.11.1-10
- Type:CVE
- ID:NA
- SUG:NA
- DESC:fix CVE-2020-28914
* Fri Jan 8 2021 LiangZhang<zhangliang5@huawei.com> - 1.11.1-9
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fixup that the getPids functions returns pid
* Thu Jan 7 2021 LiangZhang<zhangliang5@huawei.com> - 1.11.1-8
- Type:feature
- ID:NA
- SUG:NA
- DESC:add suport for stratovirt of kata-check cli
* Tue Dec 22 2020 jiangpengfei<jiangpengfei9@huawei.com> - 1.11.1-7
- Type:enhancement
- ID:NA
- SUG:update
- DESC:update kata-containers source forms of organization to move all kata-containers related source repo into one repo kata-containers
* Fri Nov 6 2020 yangfeiyu<yangfeiyu2@huawei.com> - 1.11.1-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:revert the kata-containers.spec to still build kata-containers components into one package
* Fri Oct 9 2020 yangfeiyu<yangfeiyu2@huawei.com> - 1.11.1-5
- Type:enhancement
- ID:NA
- SUG:restart
- DESC:directly copy kata binary files instead of building them
* Wed Sep 30 2020 yangfeiyu<yangfeiyu2@huawei.com> - 1.11.1-4
- Type:bugfix
- ID:NA
- SUG:restart
- DESC:kata-runtime retry inserting of CNI interface
* Sun Sep 27 2020 LiangZhang<zhangliang5@Huawei.com> - 1.11.1-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix cmd params of direct use stratovirt binary
* Sun Sep 20 2020 jiangpengf<jiangpengfei9@huawei.com> - 1.11.1-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix del-iface doesn't delete the tap interface in the host problem
* Thu Aug 27 2020 jiangpengf<jiangpengfei9@huawei.com> - 1.11.1-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:update kata-containers version to v1.11.1-1

4
kata-containers.yaml Normal file
View File

@ -0,0 +1,4 @@
version_control: github
src_repo: kata-containers/runtime
tag_prefix:
seperator: "."

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,201 @@
From c2cab7406e53db2985bec48af7f8665799f1ead6 Mon Sep 17 00:00:00 2001
From: Liu Wenyuan <liuwenyuan9@huawei.com>
Date: Wed, 23 Aug 2023 17:27:01 +0800
Subject: [PATCH 2/5] build: Makefile for StratoVirt hypervisor
Add support for building StratoVirt hypervisor, including x86_64 and
arm64.
Signed-off-by: Liu Wenyuan <liuwenyuan9@huawei.com>
---
src/runtime/Makefile | 51 ++++++++++++++++++++++++++++++-
src/runtime/arch/amd64-options.mk | 3 ++
src/runtime/arch/arm64-options.mk | 3 ++
3 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/src/runtime/Makefile b/src/runtime/Makefile
index 33fa8f2..0e6e366 100644
--- a/src/runtime/Makefile
+++ b/src/runtime/Makefile
@@ -79,6 +79,7 @@ QEMUBINDIR := $(PREFIXDEPS)/bin
CLHBINDIR := $(PREFIXDEPS)/bin
FCBINDIR := $(PREFIXDEPS)/bin
ACRNBINDIR := $(PREFIXDEPS)/bin
+STRATOVIRTBINDIR := $(PREFIXDEPS)/bin
SYSCONFDIR := /etc
LOCALSTATEDIR := /var
@@ -102,6 +103,7 @@ GENERATED_VARS = \
CONFIG_QEMU_SNP_IN \
CONFIG_CLH_IN \
CONFIG_FC_IN \
+ CONFIG_STRATOVIRT_IN \
$(USER_VARS)
SCRIPTS += $(COLLECT_SCRIPT)
SCRIPTS_DIR := $(BINDIR)
@@ -144,12 +146,13 @@ HYPERVISOR_ACRN = acrn
HYPERVISOR_FC = firecracker
HYPERVISOR_QEMU = qemu
HYPERVISOR_CLH = cloud-hypervisor
+HYPERVISOR_STRATOVIRT = stratovirt
# Determines which hypervisor is specified in $(CONFIG_FILE).
DEFAULT_HYPERVISOR ?= $(HYPERVISOR_QEMU)
# List of hypervisors this build system can generate configuration for.
-HYPERVISORS := $(HYPERVISOR_ACRN) $(HYPERVISOR_FC) $(HYPERVISOR_QEMU) $(HYPERVISOR_CLH)
+HYPERVISORS := $(HYPERVISOR_ACRN) $(HYPERVISOR_FC) $(HYPERVISOR_QEMU) $(HYPERVISOR_CLH) $(HYPERVISOR_STRATOVIRT)
QEMUPATH := $(QEMUBINDIR)/$(QEMUCMD)
QEMUVALIDHYPERVISORPATHS := [\"$(QEMUPATH)\"]
@@ -175,6 +178,9 @@ ACRNVALIDHYPERVISORPATHS := [\"$(ACRNPATH)\"]
ACRNCTLPATH := $(ACRNBINDIR)/$(ACRNCTLCMD)
ACRNVALIDCTLPATHS := [\"$(ACRNCTLPATH)\"]
+STRATOVIRTPATH = $(STRATOVIRTBINDIR)/$(STRATOVIRTCMD)
+STRATOVIRTVALIDHYPERVISORPATHS := [\"$(STRATOVIRTPATH)\"]
+
# Default number of vCPUs
DEFVCPUS := 1
# Default maximum number of vCPUs
@@ -217,6 +223,7 @@ DEFVALIDENTROPYSOURCES := [\"/dev/urandom\",\"/dev/random\",\"\"]
DEFDISABLEBLOCK := false
DEFSHAREDFS_CLH_VIRTIOFS := virtio-fs
DEFSHAREDFS_QEMU_VIRTIOFS := virtio-fs
+DEFSHAREDFS_STRATOVIRT_VIRTIOFS := virtio-fs
DEFSHAREDFS_QEMU_TDX_VIRTIOFS := virtio-9p
DEFSHAREDFS_QEMU_SEV_VIRTIOFS := virtio-9p
DEFSHAREDFS_QEMU_SNP_VIRTIOFS := virtio-9p
@@ -379,6 +386,36 @@ ifneq (,$(CLHCMD))
KERNELPATH_CLH = $(KERNELDIR)/$(KERNEL_NAME_CLH)
endif
+ifneq (,$(STRATOVIRTCMD))
+ KNOWN_HYPERVISORS += $(HYPERVISOR_STRATOVIRT)
+
+ CONFIG_FILE_STRATOVIRT = configuration-stratovirt.toml
+ CONFIG_STRATOVIRT = config/$(CONFIG_FILE_STRATOVIRT)
+ CONFIG_STRATOVIRT_IN = $(CONFIG_STRATOVIRT).in
+
+ CONFIG_PATH_STRATOVIRT = $(abspath $(CONFDIR)/$(CONFIG_FILE_STRATOVIRT))
+ CONFIG_PATHS += $(CONFIG_PATH_STRATOVIRT)
+
+ SYSCONFIG_STRATOVIRT = $(abspath $(SYSCONFDIR)/$(CONFIG_FILE_STRATOVIRT))
+ SYSCONFIG_PATHS += $(SYSCONFIG_STRATOVIRT)
+
+ CONFIGS += $(CONFIG_STRATOVIRT)
+
+ # stratovirt-specific options (all should be suffixed by "_STRATOVIRT")
+ DEFMACHINETYPE_STRATOVIRT := microvm
+ DEFBLOCKSTORAGEDRIVER_STRATOVIRT := virtio-mmio
+ DEFNETWORKMODEL_STRATOVIRT := tcfilter
+ DEFSTATICRESOURCEMGMT_STRATOVIRT = true
+ifeq ($(ARCH),amd64)
+ KERNELTYPE_STRATOVIRT = compressed
+endif
+ifeq ($(ARCH),arm64)
+ KERNELTYPE_STRATOVIRT = uncompressed
+endif
+ KERNEL_NAME_STRATOVIRT = $(call MAKE_KERNEL_NAME,$(KERNELTYPE_STRATOVIRT))
+ KERNELPATH_STRATOVIRT = $(KERNELDIR)/$(KERNEL_NAME_STRATOVIRT)
+endif
+
ifneq (,$(FCCMD))
KNOWN_HYPERVISORS += $(HYPERVISOR_FC)
@@ -477,6 +514,7 @@ USER_VARS += BINDIR
USER_VARS += CONFIG_ACRN_IN
USER_VARS += CONFIG_CLH_IN
USER_VARS += CONFIG_FC_IN
+USER_VARS += CONFIG_STRATOVIRT_IN
USER_VARS += CONFIG_PATH
USER_VARS += CONFIG_QEMU_IN
USER_VARS += DESTDIR
@@ -495,6 +533,8 @@ USER_VARS += FCPATH
USER_VARS += FCVALIDHYPERVISORPATHS
USER_VARS += FCJAILERPATH
USER_VARS += FCVALIDJAILERPATHS
+USER_VARS += STRATOVIRTPATH
+USER_VARS += STRATOVIRTVALIDHYPERVISORPATHS
USER_VARS += SYSCONFIG
USER_VARS += IMAGENAME
USER_VARS += IMAGEPATH
@@ -516,6 +556,7 @@ USER_VARS += KERNELTDXPATH
USER_VARS += KERNELSNPPATH
USER_VARS += KERNELPATH_CLH
USER_VARS += KERNELPATH_FC
+USER_VARS += KERNELPATH_STRATOVIRT
USER_VARS += KERNELVIRTIOFSPATH
USER_VARS += FIRMWAREPATH
USER_VARS += FIRMWARESEVPATH
@@ -527,6 +568,7 @@ USER_VARS += MACHINEACCELERATORS
USER_VARS += CPUFEATURES
USER_VARS += TDXCPUFEATURES
USER_VARS += DEFMACHINETYPE_CLH
+USER_VARS += DEFMACHINETYPE_STRATOVIRT
USER_VARS += KERNELPARAMS
USER_VARS += KERNELTDXPARAMS
USER_VARS += LIBEXECDIR
@@ -568,6 +610,7 @@ USER_VARS += DEFNETWORKMODEL_ACRN
USER_VARS += DEFNETWORKMODEL_CLH
USER_VARS += DEFNETWORKMODEL_FC
USER_VARS += DEFNETWORKMODEL_QEMU
+USER_VARS += DEFNETWORKMODEL_STRATOVIRT
USER_VARS += DEFDISABLEGUESTEMPTYDIR
USER_VARS += DEFDISABLEGUESTSECCOMP
USER_VARS += DEFDISABLESELINUX
@@ -578,9 +621,11 @@ USER_VARS += DEFDISABLEBLOCK
USER_VARS += DEFBLOCKSTORAGEDRIVER_ACRN
USER_VARS += DEFBLOCKSTORAGEDRIVER_FC
USER_VARS += DEFBLOCKSTORAGEDRIVER_QEMU
+USER_VARS += DEFBLOCKSTORAGEDRIVER_STRATOVIRT
USER_VARS += DEFBLOCKDEVICEAIO_QEMU
USER_VARS += DEFSHAREDFS_CLH_VIRTIOFS
USER_VARS += DEFSHAREDFS_QEMU_VIRTIOFS
+USER_VARS += DEFSHAREDFS_STRATOVIRT_VIRTIOFS
USER_VARS += DEFSHAREDFS_QEMU_TDX_VIRTIOFS
USER_VARS += DEFSHAREDFS_QEMU_SEV_VIRTIOFS
USER_VARS += DEFSHAREDFS_QEMU_SNP_VIRTIOFS
@@ -605,6 +650,7 @@ USER_VARS += DEFSANDBOXCGROUPONLY
USER_VARS += DEFSTATICRESOURCEMGMT
USER_VARS += DEFSTATICRESOURCEMGMT_CLH
USER_VARS += DEFSTATICRESOURCEMGMT_FC
+USER_VARS += DEFSTATICRESOURCEMGMT_STRATOVIRT
USER_VARS += DEFSTATICRESOURCEMGMT_TEE
USER_VARS += DEFBINDMOUNTS
USER_VARS += DEFSERVICEOFFLOAD
@@ -936,6 +982,9 @@ ifneq (,$(findstring $(HYPERVISOR_FC),$(KNOWN_HYPERVISORS)))
endif
ifneq (,$(findstring $(HYPERVISOR_ACRN),$(KNOWN_HYPERVISORS)))
@printf "\t$(HYPERVISOR_ACRN) hypervisor path (ACRNPATH) : %s\n" $(abspath $(ACRNPATH))
+endif
+ifneq (,$(findstring $(HYPERVISOR_STRATOVIRT),$(KNOWN_HYPERVISORS)))
+ @printf "\t$(HYPERVISOR_STRATOVIRT) hypervisor path (STRATOVIRTPATH) : %s\n" $(abspath $(STRATOVIRTPATH))
endif
@printf "\tassets path (PKGDATADIR) : %s\n" $(abspath $(PKGDATADIR))
@printf "\tshim path (PKGLIBEXECDIR) : %s\n" $(abspath $(PKGLIBEXECDIR))
diff --git a/src/runtime/arch/amd64-options.mk b/src/runtime/arch/amd64-options.mk
index e606815..940e87a 100644
--- a/src/runtime/arch/amd64-options.mk
+++ b/src/runtime/arch/amd64-options.mk
@@ -28,3 +28,6 @@ ACRNCTLCMD := acrnctl
CLHCMD := cloud-hypervisor
DEFSTATICRESOURCEMGMT_CLH := false
+
+# stratovirt binary name
+STRATOVIRTCMD := stratovirt
diff --git a/src/runtime/arch/arm64-options.mk b/src/runtime/arch/arm64-options.mk
index 7f74ae3..895c93f 100644
--- a/src/runtime/arch/arm64-options.mk
+++ b/src/runtime/arch/arm64-options.mk
@@ -21,3 +21,6 @@ FCJAILERCMD := jailer
CLHCMD := cloud-hypervisor
DEFSTATICRESOURCEMGMT_CLH := true
+
+# stratovirt binary name
+STRATOVIRTCMD := stratovirt
--
2.34.1

View File

@ -0,0 +1,548 @@
From 2d0431ff3051b9267919a543906c8fd5547facf9 Mon Sep 17 00:00:00 2001
From: Liu Wenyuan <liuwenyuan9@huawei.com>
Date: Wed, 23 Aug 2023 17:49:56 +0800
Subject: [PATCH 3/5] configuration: add configuration for StratoVirt
hypervisor.
Add configuration-stratovirt.toml.in to generate the StratoVirt configuration,
and parser to deliver config to StratoVirt.
Signed-off-by: Liu Wenyuan <liuwenyuan9@huawei.com>
---
.../config/configuration-stratovirt.toml.in | 394 ++++++++++++++++++
src/runtime/pkg/katautils/config.go | 104 +++++
2 files changed, 498 insertions(+)
create mode 100644 src/runtime/config/configuration-stratovirt.toml.in
diff --git a/src/runtime/config/configuration-stratovirt.toml.in b/src/runtime/config/configuration-stratovirt.toml.in
new file mode 100644
index 0000000..c98cf6b
--- /dev/null
+++ b/src/runtime/config/configuration-stratovirt.toml.in
@@ -0,0 +1,394 @@
+# Copyright (c) 2023 Huawei Technologies Co.,Ltd.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+# XXX: WARNING: this file is auto-generated.
+# XXX:
+# XXX: Source file: "@CONFIG_STRATOVIRT_IN@"
+# XXX: Project:
+# XXX: Name: @PROJECT_NAME@
+# XXX: Type: @PROJECT_TYPE@
+
+[hypervisor.stratovirt]
+path = "@STRATOVIRTPATH@"
+kernel = "@KERNELPATH_STRATOVIRT@"
+#image = "@IMAGEPATH@"
+initrd = "@INITRDPATH@"
+machine_type = "@DEFMACHINETYPE_STRATOVIRT@"
+
+# rootfs filesystem type:
+# - ext4 (default)
+# - xfs
+# - erofs
+rootfs_type = @DEFROOTFSTYPE@
+
+# List of valid annotation names for the hypervisor
+# Each member of the list is a regular expression, which is the base name
+# of the annotation, e.g. "path" for io.katacontainers.config.hypervisor.path"
+enable_annotations = @DEFENABLEANNOTATIONS@
+
+# List of valid annotations values for the hypervisor
+# Each member of the list is a path pattern as described by glob(3).
+# The default if not set is empty (all annotations rejected.)
+# Your distribution recommends: @STRATOVIRTVALIDHYPERVISORPATHS@
+valid_hypervisor_paths = @STRATOVIRTVALIDHYPERVISORPATHS@
+
+# Optional space-separated list of options to pass to the guest kernel.
+# For example, use `kernel_params = "vsyscall=emulate"` if you are having
+# trouble running pre-2.15 glibc.
+#
+# WARNING: - any parameter specified here will take priority over the default
+# parameter value of the same name used to start the virtual machine.
+# Do not set values here unless you understand the impact of doing so as you
+# may stop the virtual machine from booting.
+# To see the list of default parameters, enable hypervisor debug, create a
+# container and look for 'default-kernel-parameters' log entries.
+kernel_params = "@KERNELPARAMS@"
+
+# Default number of vCPUs per SB/VM:
+# unspecified or 0 --> will be set to @DEFVCPUS@
+# < 0 --> will be set to the actual number of physical cores
+# > 0 <= number of physical cores --> will be set to the specified number
+# > number of physical cores --> will be set to the actual number of physical cores
+default_vcpus = 1
+
+# Default maximum number of vCPUs per SB/VM:
+# unspecified or == 0 --> will be set to the actual number of physical cores or to the maximum number
+# of vCPUs supported by KVM if that number is exceeded
+# > 0 <= number of physical cores --> will be set to the specified number
+# > number of physical cores --> will be set to the actual number of physical cores or to the maximum number
+# of vCPUs supported by KVM if that number is exceeded
+# WARNING: Depending of the architecture, the maximum number of vCPUs supported by KVM is used when
+# the actual number of physical cores is greater than it.
+# WARNING: Be aware that this value impacts the virtual machine's memory footprint and CPU
+# the hotplug functionality. For example, `default_maxvcpus = 240` specifies that until 240 vCPUs
+# can be added to a SB/VM, but the memory footprint will be big. Another example, with
+# `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of
+# vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable,
+# unless you know what are you doing.
+# NOTICE: on arm platform with gicv2 interrupt controller, set it to 8.
+default_maxvcpus = @DEFMAXVCPUS@
+
+# Bridges can be used to hot plug devices.
+# Limitations:
+# * Currently only pci bridges are supported
+# * Until 30 devices per bridge can be hot plugged.
+# * Until 5 PCI bridges can be cold plugged per VM.
+# This limitation could be a bug in the kernel
+# Default number of bridges per SB/VM:
+# unspecified or 0 --> will be set to @DEFBRIDGES@
+# > 1 <= 5 --> will be set to the specified number
+# > 5 --> will be set to 5
+default_bridges = @DEFBRIDGES@
+
+# Default memory size in MiB for SB/VM.
+# If unspecified then it will be set @DEFMEMSZ@ MiB.
+default_memory = @DEFMEMSZ@
+#
+# Default memory slots per SB/VM.
+# If unspecified then it will be set @DEFMEMSLOTS@.
+# This is will determine the times that memory will be hotadded to sandbox/VM.
+#memory_slots = @DEFMEMSLOTS@
+
+# Default maximum memory in MiB per SB / VM
+# unspecified or == 0 --> will be set to the actual amount of physical RAM
+# > 0 <= amount of physical RAM --> will be set to the specified number
+# > amount of physical RAM --> will be set to the actual amount of physical RAM
+default_maxmemory = @DEFMAXMEMSZ@
+
+# The size in MiB will be plused to max memory of hypervisor.
+# It is the memory address space for the NVDIMM devie.
+# If set block storage driver (block_device_driver) to "nvdimm",
+# should set memory_offset to the size of block device.
+# Default 0
+#memory_offset = 0
+
+# Disable block device from being used for a container's rootfs.
+# In case of a storage driver like devicemapper where a container's
+# root file system is backed by a block device, the block device is passed
+# directly to the hypervisor for performance reasons.
+# This flag prevents the block device from being passed to the hypervisor,
+# virtio-fs is used instead to pass the rootfs.
+disable_block_device_use = @DEFDISABLEBLOCK@
+
+# Shared file system type:
+# - virtio-fs (default)
+# - virtio-fs-nydus
+# - none
+shared_fs = "@DEFSHAREDFS_STRATOVIRT_VIRTIOFS@"
+
+# Path to vhost-user-fs daemon.
+virtio_fs_daemon = "@DEFVIRTIOFSDAEMON@"
+
+# List of valid annotations values for the virtiofs daemon
+# The default if not set is empty (all annotations rejected.)
+valid_virtio_fs_daemon_paths = @DEFVALIDVIRTIOFSDAEMONPATHS@
+
+# Default size of DAX cache in MiB
+virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@
+
+# Extra args for virtiofsd daemon
+#
+# Format example:
+# ["--arg1=xxx", "--arg2=yyy"]
+# Examples:
+# Set virtiofsd log level to debug : ["--log-level=debug"]
+#
+# see `virtiofsd -h` for possible options.
+virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
+
+# Cache mode:
+#
+# - never
+# Metadata, data, and pathname lookup are not cached in guest. They are
+# always fetched from host and any changes are immediately pushed to host.
+#
+# - auto
+# Metadata and pathname lookup cache expires after a configured amount of
+# time (default is 1 second). Data is cached while the file is open (close
+# to open consistency).
+#
+# - always
+# Metadata, data, and pathname lookup are cached in guest and never expire.
+virtio_fs_cache = "@DEFVIRTIOFSCACHE@"
+
+# Block storage driver to be used for the hypervisor in case the container
+# rootfs is backed by a block device. This is virtio-scsi, virtio-blk
+# or nvdimm.
+block_device_driver = "@DEFBLOCKSTORAGEDRIVER_STRATOVIRT@"
+
+# Specifies cache-related options will be set to block devices or not.
+# Default false
+#block_device_cache_set = true
+
+# Specifies cache-related options for block devices.
+# Denotes whether use of O_DIRECT (bypass the host page cache) is enabled.
+# Default false
+#block_device_cache_direct = true
+
+# Specifies cache-related options for block devices.
+# Denotes whether flush requests for the device are ignored.
+# Default false
+#block_device_cache_noflush = true
+
+# Enable huge pages for VM RAM, default false
+# Enabling this will result in the VM memory
+# being allocated using huge pages.
+# This is useful when you want to use vhost-user network
+# stacks within the container. This will automatically
+# result in memory pre allocation
+#enable_hugepages = true
+
+# Enable vIOMMU, default false
+# Enabling this will result in the VM having a vIOMMU device
+# This will also add the following options to the kernel's
+# command line: intel_iommu=on,iommu=pt
+#enable_iommu = true
+
+# This option changes the default hypervisor and kernel parameters
+# to enable debug output where available.
+#
+# Default false
+#enable_debug = true
+
+# Disable the customizations done in the runtime when it detects
+# that it is running on top a VMM. This will result in the runtime
+# behaving as it would when running on bare metal.
+#
+#disable_nesting_checks = true
+
+#
+# Default entropy source.
+# The path to a host source of entropy (including a real hardware RNG)
+# /dev/urandom and /dev/random are two main options.
+# Be aware that /dev/random is a blocking source of entropy. If the host
+# runs out of entropy, the VMs boot time will increase leading to get startup
+# timeouts.
+# The source of entropy /dev/urandom is non-blocking and provides a
+# generally acceptable source of entropy. It should work well for pretty much
+# all practical purposes.
+entropy_source = "@DEFENTROPYSOURCE@"
+
+# Path to OCI hook binaries in the *guest rootfs*.
+# This does not affect host-side hooks which must instead be added to
+# the OCI spec passed to the runtime.
+#
+# You can create a rootfs with hooks by customizing the osbuilder scripts:
+# https://github.com/kata-containers/kata-containers/tree/main/tools/osbuilder
+#
+# Hooks must be stored in a subdirectory of guest_hook_path according to their
+# hook type, i.e. "guest_hook_path/{prestart,poststart,poststop}".
+# The agent will scan these directories for executable files and add them, in
+# lexicographical order, to the lifecycle of the guest container.
+# Hooks are executed in the runtime namespace of the guest. See the official documentation:
+# https://github.com/opencontainers/runtime-spec/blob/v1.0.1/config.md#posix-platform-hooks
+# Warnings will be logged if any error is encountered while scanning for hooks,
+# but it will not abort container execution.
+#guest_hook_path = "/usr/share/oci/hooks"
+
+# disable applying SELinux on the VMM process (default false)
+disable_selinux = @DEFDISABLESELINUX@
+
+# disable applying SELinux on the container process
+# If set to false, the type `container_t` is applied to the container process by default.
+# Note: To enable guest SELinux, the guest rootfs must be CentOS that is created and built
+# with `SELINUX=yes`.
+# (default: true)
+disable_guest_selinux = @DEFDISABLEGUESTSELINUX@
+
+[factory]
+# VM templating support. Once enabled, new VMs are created from template
+# using vm cloning. They will share the same initial kernel, initramfs and
+# agent memory by mapping it readonly. It helps speeding up new container
+# creation and saves a lot of memory if there are many kata containers running
+# on the same host.
+#
+# When disabled, new VMs are created from scratch.
+#
+# Note: Requires "initrd=" to be set ("image=" is not supported).
+#
+# Default false
+#enable_template = true
+
+[agent.@PROJECT_TYPE@]
+# If enabled, make the agent display debug-level messages.
+# (default: disabled)
+#enable_debug = true
+
+# Enable agent tracing.
+#
+# If enabled, the agent will generate OpenTelemetry trace spans.
+#
+# Notes:
+#
+# - If the runtime also has tracing enabled, the agent spans will be
+# associated with the appropriate runtime parent span.
+# - If enabled, the runtime will wait for the container to shutdown,
+# increasing the container shutdown time slightly.
+#
+# (default: disabled)
+#enable_tracing = true
+
+# Comma separated list of kernel modules and their parameters.
+# These modules will be loaded in the guest kernel using modprobe(8).
+# The following example can be used to load two kernel modules with parameters
+# - kernel_modules=["e1000e InterruptThrottleRate=3000,3000,3000 EEE=1", "i915 enable_ppgtt=0"]
+# The first word is considered as the module name and the rest as its parameters.
+# Container will not be started when:
+# * A kernel module is specified and the modprobe command is not installed in the guest
+# or it fails loading the module.
+# * The module is not available in the guest or it doesn't met the guest kernel
+# requirements, like architecture and version.
+#
+kernel_modules = []
+
+# Enable debug console.
+
+# If enabled, user can connect guest OS running inside hypervisor
+# through "kata-runtime exec <sandbox-id>" command
+
+#debug_console_enabled = true
+
+# Agent connection dialing timeout value in seconds
+# (default: 45)
+dial_timeout = 45
+
+[runtime]
+# If enabled, the runtime will log additional debug messages to the
+# system log
+# (default: disabled)
+#enable_debug = true
+#
+# Internetworking model
+# Determines how the VM should be connected to the
+# the container network interface
+# Options:
+#
+# - macvtap
+# Used when the Container network interface can be bridged using
+# macvtap.
+#
+# - none
+# Used when customize network. Only creates a tap device. No veth pair.
+#
+# - tcfilter
+# Uses tc filter rules to redirect traffic from the network interface
+# provided by plugin to a tap interface connected to the VM.
+#
+internetworking_model = "@DEFNETWORKMODEL_STRATOVIRT@"
+
+# disable guest seccomp
+# Determines whether container seccomp profiles are passed to the virtual
+# machine and applied by the kata agent. If set to true, seccomp is not applied
+# within the guest
+# (default: true)
+disable_guest_seccomp = @DEFDISABLEGUESTSECCOMP@
+
+# vCPUs pinning settings
+# if enabled, each vCPU thread will be scheduled to a fixed CPU
+# qualified condition: num(vCPU threads) == num(CPUs in sandbox's CPUSet)
+#enable_vcpus_pinning = false
+
+# Apply a custom SELinux security policy to the container process inside the VM.
+# This is used when you want to apply a type other than the default `container_t`,
+# so general users should not uncomment and apply it.
+# (format: "user:role:type")
+# Note: You cannot specify MCS policy with the label because the sensitivity levels and
+# categories are determined automatically by high-level container runtimes such as containerd.
+#guest_selinux_label = "@DEFGUESTSELINUXLABEL@"
+
+# If enabled, the runtime will create opentracing.io traces and spans.
+# (See https://www.jaegertracing.io/docs/getting-started).
+# (default: disabled)
+#enable_tracing = true
+
+# Set the full url to the Jaeger HTTP Thrift collector.
+# The default if not set will be "http://localhost:14268/api/traces"
+#jaeger_endpoint = ""
+
+# Sets the username to be used if basic auth is required for Jaeger.
+#jaeger_user = ""
+
+# Sets the password to be used if basic auth is required for Jaeger.
+#jaeger_password = ""
+
+# If enabled, the runtime will not create a network namespace for shim and hypervisor processes.
+# This option may have some potential impacts to your host. It should only be used when you know what you're doing.
+# `disable_new_netns` conflicts with `internetworking_model=tcfilter` and `internetworking_model=macvtap`. It works only
+# with `internetworking_model=none`. The tap device will be in the host network namespace and can connect to a bridge
+# (like OVS) directly.
+# (default: false)
+#disable_new_netns = true
+
+# if enabled, the runtime will add all the kata processes inside one dedicated cgroup.
+# The container cgroups in the host are not created, just one single cgroup per sandbox.
+# The runtime caller is free to restrict or collect cgroup stats of the overall Kata sandbox.
+# The sandbox cgroup path is the parent cgroup of a container with the PodSandbox annotation.
+# The sandbox cgroup is constrained if there is no container type annotation.
+# See: https://pkg.go.dev/github.com/kata-containers/kata-containers/src/runtime/virtcontainers#ContainerType
+sandbox_cgroup_only = @DEFSANDBOXCGROUPONLY@
+
+# If enabled, the runtime will attempt to determine appropriate sandbox size (memory, CPU) before booting the virtual machine. In
+# this case, the runtime will not dynamically update the amount of memory and CPU in the virtual machine. This is generally helpful
+# when a hardware architecture or hypervisor solutions is utilized which does not support CPU and/or memory hotplug.
+# Compatibility for determining appropriate sandbox (VM) size:
+# - When running with pods, sandbox sizing information will only be available if using Kubernetes >= 1.23 and containerd >= 1.6. CRI-O
+# does not yet support sandbox sizing annotations.
+# - When running single containers using a tool like ctr, container sizing information will be available.
+static_sandbox_resource_mgmt = @DEFSTATICRESOURCEMGMT_STRATOVIRT@
+
+# If enabled, the runtime will not create Kubernetes emptyDir mounts on the guest filesystem. Instead, emptyDir mounts will
+# be created on the host and shared via virtio-fs. This is potentially slower, but allows sharing of files from host to guest.
+disable_guest_empty_dir = @DEFDISABLEGUESTEMPTYDIR@
+
+# Enabled experimental feature list, format: ["a", "b"].
+# Experimental features are features not stable enough for production,
+# they may break compatibility, and are prepared for a big version bump.
+# Supported experimental features:
+# (default: [])
+experimental = @DEFAULTEXPFEATURES@
+
+# If enabled, user can run pprof tools with shim v2 process through kata-monitor.
+# (default: false)
+#enable_pprof = true
diff --git a/src/runtime/pkg/katautils/config.go b/src/runtime/pkg/katautils/config.go
index feeef68..45bbfea 100644
--- a/src/runtime/pkg/katautils/config.go
+++ b/src/runtime/pkg/katautils/config.go
@@ -52,6 +52,7 @@ const (
qemuHypervisorTableType = "qemu"
acrnHypervisorTableType = "acrn"
dragonballHypervisorTableType = "dragonball"
+ stratovirtHypervisorTableType = "stratovirt"
// the maximum amount of PCI bridges that can be cold plugged in a VM
maxPCIBridges uint32 = 5
@@ -1142,6 +1143,106 @@ func newDragonballHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
}, nil
}
+func newStratovirtHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
+ hypervisor, err := h.path()
+ if err != nil {
+ return vc.HypervisorConfig{}, err
+ }
+
+ kernel, err := h.kernel()
+ if err != nil {
+ return vc.HypervisorConfig{}, err
+ }
+
+ initrd, err := h.initrd()
+ if err != nil {
+ return vc.HypervisorConfig{}, err
+ }
+
+ image, err := h.image()
+ if err != nil {
+ return vc.HypervisorConfig{}, err
+ }
+
+ if image != "" && initrd != "" {
+ return vc.HypervisorConfig{},
+ errors.New("having both an image and an initrd defined in the configuration file is not supported")
+ }
+
+ if image == "" && initrd == "" {
+ return vc.HypervisorConfig{},
+ errors.New("image or initrd must be defined in the configuration file")
+ }
+
+ rootfsType, err := h.rootfsType()
+ if err != nil {
+ return vc.HypervisorConfig{}, err
+ }
+
+ kernelParams := h.kernelParams()
+ machineType := h.machineType()
+
+ blockDriver, err := h.blockDeviceDriver()
+ if err != nil {
+ return vc.HypervisorConfig{}, err
+ }
+
+ if vSock, err := utils.SupportsVsocks(); !vSock {
+ return vc.HypervisorConfig{}, err
+ }
+
+ sharedFS, err := h.sharedFS()
+ if err != nil {
+ return vc.HypervisorConfig{}, err
+ }
+
+ if sharedFS != config.VirtioFS && sharedFS != config.VirtioFSNydus && sharedFS != config.NoSharedFS {
+ return vc.HypervisorConfig{},
+ fmt.Errorf("Stratovirt Hypervisor does not support %s shared filesystem option", sharedFS)
+ }
+
+ if (sharedFS == config.VirtioFS || sharedFS == config.VirtioFSNydus) && h.VirtioFSDaemon == "" {
+ return vc.HypervisorConfig{},
+ fmt.Errorf("cannot enable %s without daemon path in configuration file", sharedFS)
+ }
+
+ return vc.HypervisorConfig{
+ HypervisorPath: hypervisor,
+ HypervisorPathList: h.HypervisorPathList,
+ KernelPath: kernel,
+ InitrdPath: initrd,
+ ImagePath: image,
+ RootfsType: rootfsType,
+ KernelParams: vc.DeserializeParams(strings.Fields(kernelParams)),
+ HypervisorMachineType: machineType,
+ NumVCPUs: h.defaultVCPUs(),
+ DefaultMaxVCPUs: h.defaultMaxVCPUs(),
+ MemorySize: h.defaultMemSz(),
+ MemSlots: h.defaultMemSlots(),
+ MemOffset: h.defaultMemOffset(),
+ DefaultMaxMemorySize: h.defaultMaxMemSz(),
+ EntropySource: h.GetEntropySource(),
+ DefaultBridges: h.defaultBridges(),
+ DisableBlockDeviceUse: h.DisableBlockDeviceUse,
+ SharedFS: sharedFS,
+ VirtioFSDaemon: h.VirtioFSDaemon,
+ VirtioFSDaemonList: h.VirtioFSDaemonList,
+ VirtioFSCacheSize: h.VirtioFSCacheSize,
+ VirtioFSCache: h.defaultVirtioFSCache(),
+ VirtioFSExtraArgs: h.VirtioFSExtraArgs,
+ HugePages: h.HugePages,
+ Debug: h.Debug,
+ DisableNestingChecks: h.DisableNestingChecks,
+ BlockDeviceDriver: blockDriver,
+ DisableVhostNet: true,
+ GuestHookPath: h.guestHookPath(),
+ EnableAnnotations: h.EnableAnnotations,
+ DisableSeccomp: h.DisableSeccomp,
+ DisableSeLinux: h.DisableSeLinux,
+ DisableGuestSeLinux: h.DisableGuestSeLinux,
+ }, nil
+}
+
func newFactoryConfig(f factory) (oci.FactoryConfig, error) {
if f.TemplatePath == "" {
f.TemplatePath = defaultTemplatePath
@@ -1178,6 +1279,9 @@ func updateRuntimeConfigHypervisor(configPath string, tomlConf tomlConfig, confi
case dragonballHypervisorTableType:
config.HypervisorType = vc.DragonballHypervisor
hConfig, err = newDragonballHypervisorConfig(hypervisor)
+ case stratovirtHypervisorTableType:
+ config.HypervisorType = vc.StratovirtHypervisor
+ hConfig, err = newStratovirtHypervisorConfig(hypervisor)
default:
err = fmt.Errorf("%s: %+q", errInvalidHypervisorPrefix, k)
}
--
2.34.1

View File

@ -0,0 +1,246 @@
From a89fca251514dee26b4e6e077f4a0484a2d45a5f Mon Sep 17 00:00:00 2001
From: Liu Wenyuan <liuwenyuan9@huawei.com>
Date: Fri, 1 Sep 2023 20:44:30 +0800
Subject: [PATCH 4/5] kata-deploy: Add StratoVirt support to deploy process
Allow kata-deploy process to pull StratoVirt from release binaries, and
add them as a part of kata release.
Signed-off-by: Liu Wenyuan <liuwenyuan9@huawei.com>
---
.../kata-cleanup/base/kata-cleanup.yaml | 2 +-
.../kata-deploy/base/kata-deploy.yaml | 2 +-
.../kata-deploy/local-build/Makefile | 4 ++
.../local-build/kata-deploy-binaries.sh | 28 ++++++++++++++
.../runtimeclasses/kata-runtimeClasses.yaml | 13 +++++++
.../runtimeclasses/kata-stratovirt.yaml | 13 +++++++
.../stratovirt/build-static-stratovirt.sh | 37 +++++++++++++++++++
versions.yaml | 5 +++
8 files changed, 102 insertions(+), 2 deletions(-)
create mode 100644 tools/packaging/kata-deploy/runtimeclasses/kata-stratovirt.yaml
create mode 100755 tools/packaging/static-build/stratovirt/build-static-stratovirt.sh
diff --git a/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml b/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml
index df1a2ff..4814b93 100644
--- a/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml
+++ b/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml
@@ -30,7 +30,7 @@ spec:
- name: DEBUG
value: "false"
- name: SHIMS
- value: "clh dragonball fc qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx qemu"
+ value: "clh dragonball fc qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx qemu stratovirt"
- name: DEFAULT_SHIM
value: "qemu"
- name: CREATE_RUNTIMECLASSES
diff --git a/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml b/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml
index 383eec9..52e5987 100644
--- a/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml
+++ b/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml
@@ -32,7 +32,7 @@ spec:
- name: DEBUG
value: "false"
- name: SHIMS
- value: "clh dragonball fc qemu qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx"
+ value: "clh dragonball fc qemu qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx stratovirt"
- name: DEFAULT_SHIM
value: "qemu"
- name: CREATE_RUNTIMECLASSES
diff --git a/tools/packaging/kata-deploy/local-build/Makefile b/tools/packaging/kata-deploy/local-build/Makefile
index d9e28a5..ef63f2f 100644
--- a/tools/packaging/kata-deploy/local-build/Makefile
+++ b/tools/packaging/kata-deploy/local-build/Makefile
@@ -35,6 +35,7 @@ all: serial-targets \
qemu-snp-experimental-tarball \
qemu-tarball \
qemu-tdx-experimental-tarball \
+ stratovirt-tarball \
shim-v2-tarball \
tdvf-tarball \
virtiofsd-tarball
@@ -112,6 +113,9 @@ qemu-tarball:
qemu-tdx-experimental-tarball:
${MAKE} $@-build
+stratovirt-tarball:
+ ${MAKE} $@-build
+
rootfs-image-tarball:
${MAKE} $@-build
diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh
index bb68d88..70e07b4 100755
--- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh
+++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh
@@ -30,6 +30,7 @@ readonly kernel_builder="${static_build_dir}/kernel/build.sh"
readonly ovmf_builder="${static_build_dir}/ovmf/build.sh"
readonly qemu_builder="${static_build_dir}/qemu/build-static-qemu.sh"
readonly qemu_experimental_builder="${static_build_dir}/qemu/build-static-qemu-experimental.sh"
+readonly stratovirt_builder="${static_build_dir}/stratovirt/build-static-stratovirt.sh"
readonly shimv2_builder="${static_build_dir}/shim-v2/build.sh"
readonly virtiofsd_builder="${static_build_dir}/virtiofsd/build.sh"
readonly nydus_builder="${static_build_dir}/nydus/build.sh"
@@ -103,6 +104,7 @@ options:
qemu
qemu-snp-experimental
qemu-tdx-experimental
+ stratovirt
rootfs-image
rootfs-image-tdx
rootfs-initrd
@@ -511,6 +513,28 @@ install_clh_glibc() {
install_clh_helper "gnu" "${features}" "-glibc"
}
+# Install static stratovirt asset
+install_stratovirt() {
+ local stratovirt_version=$(get_from_kata_deps "assets.hypervisor.stratovirt.version")
+
+ latest_artefact="${stratovirt_version}"
+ latest_builder_image=""
+
+ install_cached_tarball_component \
+ "stratovirt" \
+ "${latest_artefact}" \
+ "${latest_builder_image}" \
+ "${final_tarball_name}" \
+ "${final_tarball_path}" \
+ && return 0
+
+ info "build static stratovirt"
+ "${stratovirt_builder}"
+ info "Install static stratovirt"
+ mkdir -p "${destdir}/opt/kata/bin/"
+ sudo install -D --owner root --group root --mode 0744 static-stratovirt/stratovirt "${destdir}/opt/kata/bin/stratovirt"
+}
+
# Install static virtiofsd asset
install_virtiofsd() {
latest_artefact="$(get_from_kata_deps "externals.virtiofsd.version")-$(get_from_kata_deps "externals.virtiofsd.toolchain")"
@@ -734,6 +758,7 @@ handle_build() {
install_qemu
install_qemu_snp_experimental
install_qemu_tdx_experimental
+ install_stratovirt
install_runk
install_shimv2
install_tdvf
@@ -781,6 +806,8 @@ handle_build() {
qemu-tdx-experimental) install_qemu_tdx_experimental ;;
+ stratovirt) install_stratovirt ;;
+
rootfs-image) install_image ;;
rootfs-image-tdx) install_image_tdx ;;
@@ -860,6 +887,7 @@ main() {
log-parser-rs
nydus
qemu
+ stratovirt
rootfs-image
rootfs-initrd
rootfs-initrd-mariner
diff --git a/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml b/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml
index e67cafe..ae3c8c8 100644
--- a/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml
+++ b/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml
@@ -102,3 +102,16 @@ overhead:
scheduling:
nodeSelector:
katacontainers.io/kata-runtime: "true"
+---
+kind: RuntimeClass
+apiVersion: node.k8s.io/v1
+metadata:
+ name: kata-stratovirt
+handler: kata-stratovirt
+overhead:
+ podFixed:
+ memory: "130Mi"
+ cpu: "250m"
+scheduling:
+ nodeSelector:
+ katacontainers.io/kata-runtime: "true"
diff --git a/tools/packaging/kata-deploy/runtimeclasses/kata-stratovirt.yaml b/tools/packaging/kata-deploy/runtimeclasses/kata-stratovirt.yaml
new file mode 100644
index 0000000..ea27046
--- /dev/null
+++ b/tools/packaging/kata-deploy/runtimeclasses/kata-stratovirt.yaml
@@ -0,0 +1,13 @@
+---
+kind: RuntimeClass
+apiVersion: node.k8s.io/v1
+metadata:
+ name: kata-stratovirt
+handler: kata-stratovirt
+overhead:
+ podFixed:
+ memory: "130Mi"
+ cpu: "250m"
+scheduling:
+ nodeSelector:
+ katacontainers.io/kata-runtime: "true"
diff --git a/tools/packaging/static-build/stratovirt/build-static-stratovirt.sh b/tools/packaging/static-build/stratovirt/build-static-stratovirt.sh
new file mode 100755
index 0000000..2fe28aa
--- /dev/null
+++ b/tools/packaging/static-build/stratovirt/build-static-stratovirt.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023 Huawei Technologies Co.,Ltd.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+ARCH=$(uname -m)
+
+# Currently, StratoVirt only support x86_64 and aarch64.
+[ "${ARCH}" != "x86_64" ] && [ "${ARCH}" != "aarch64" ] && exit
+
+script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+source "${script_dir}/../../scripts/lib.sh"
+
+info "Get stratovirt information from runtime versions.yaml"
+stratovirt_url="${stratovirt_url:-}"
+[ -n "$stratovirt_url" ] || stratovirt_url=$(get_from_kata_deps "assets.hypervisor.stratovirt.url")
+[ -n "$stratovirt_url" ] || die "failed to get stratovirt url"
+
+stratovirt_version="${stratovirt_version:-}"
+[ -n "$stratovirt_version" ] || stratovirt_version=$(get_from_kata_deps "assets.hypervisor.stratovirt.version")
+[ -n "$stratovirt_version" ] || die "failed to get stratovirt version"
+
+pull_stratovirt_released_binary() {
+ file_name="stratovirt-static-${stratovirt_version##*v}-${ARCH}"
+ download_url="${stratovirt_url}/releases/download/${stratovirt_version}/${file_name}.tar.gz"
+
+ curl -L ${download_url} -o ${file_name}.tar.gz
+ mkdir -p static-stratovirt
+ tar zxvf ${file_name}.tar.gz -C static-stratovirt
+}
+
+pull_stratovirt_released_binary
diff --git a/versions.yaml b/versions.yaml
index 57e3c94..3b5f37a 100644
--- a/versions.yaml
+++ b/versions.yaml
@@ -115,6 +115,11 @@ assets:
url: "https://github.com/AMDESE/qemu"
tag: "3b6a2b6b7466f6dea53243900b7516c3f29027b7"
+ stratovirt:
+ description: "StratoVirt is an lightweight opensource VMM"
+ url: "https://github.com/openeuler-mirror/stratovirt"
+ version: "v2.3.0"
+
image:
description: |
Root filesystem disk image used to boot the guest virtual
--
2.34.1

View File

@ -0,0 +1,60 @@
From 0fb8c1bd205397ee2efd070dc525a17e9a787857 Mon Sep 17 00:00:00 2001
From: Zhigang Wang <wangzhigang17@huawei.com>
Date: Mon, 1 Jan 2024 21:51:25 +0800
Subject: [PATCH 5/5] mount: Reduce the mount points with namespace isolation
This patch can reduce load on systemd process, and
increase the k8s deployment density when using go runtime.
Signed-off-by: Zhigang Wang <wangzhigang17@huawei.com>
Signed-off-by: Liu Wenyuan <liuwenyuan9@huawei.com>
---
src/runtime/pkg/containerd-shim-v2/service.go | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/src/runtime/pkg/containerd-shim-v2/service.go b/src/runtime/pkg/containerd-shim-v2/service.go
index 26d4c21..7b06429 100644
--- a/src/runtime/pkg/containerd-shim-v2/service.go
+++ b/src/runtime/pkg/containerd-shim-v2/service.go
@@ -191,6 +191,27 @@ func newCommand(ctx context.Context, id, containerdBinary, containerdAddress str
return cmd, nil
}
+func setupMntNs() error {
+ err := unix.Unshare(unix.CLONE_NEWNS)
+ if err != nil {
+ return err
+ }
+
+ err = unix.Mount("", "/", "", unix.MS_REC|unix.MS_SLAVE, "")
+ if err != nil {
+ err = fmt.Errorf("failed to mount with slave: %v", err)
+ return err
+ }
+
+ err = unix.Mount("", "/", "", unix.MS_REC|unix.MS_SHARED, "")
+ if err != nil {
+ err = fmt.Errorf("failed to mount with shared: %v", err)
+ return err
+ }
+
+ return nil
+}
+
// StartShim is a binary call that starts a kata shimv2 service which will
// implement the ShimV2 APIs such as create/start/update etc containers.
func (s *service) StartShim(ctx context.Context, opts cdshim.StartOpts) (_ string, retErr error) {
@@ -255,6 +276,10 @@ func (s *service) StartShim(ctx context.Context, opts cdshim.StartOpts) (_ strin
}
}
+ if err := setupMntNs(); err != nil {
+ return "", err
+ }
+
if err := cmd.Start(); err != nil {
return "", err
}
--
2.34.1

View File

@ -0,0 +1,26 @@
From 5a85bf2eb90ce9403f3f11e04ae3d5ba35db322a Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Mon, 29 Apr 2024 05:44:44 +0800
Subject: [PATCH] Allow swappiness to be -1 as default
Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---
src/agent/rustjail/src/cgroups/fs/mod.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/agent/rustjail/src/cgroups/fs/mod.rs b/src/agent/rustjail/src/cgroups/fs/mod.rs
index 6145f5f..c49d041 100644
--- a/src/agent/rustjail/src/cgroups/fs/mod.rs
+++ b/src/agent/rustjail/src/cgroups/fs/mod.rs
@@ -475,7 +475,7 @@ fn set_memory_resources(cg: &cgroups::Cgroup, memory: &LinuxMemory, update: bool
if let Some(swappiness) = memory.swappiness {
if (0..=100).contains(&swappiness) {
mem_controller.set_swappiness(swappiness)?;
- } else {
+ } else if swappiness != (-1i64 as u64){
return Err(anyhow!(
"invalid value:{}. valid memory swappiness range is 0-100",
swappiness
--
2.33.0

View File

@ -0,0 +1,338 @@
From 52f4da0246fa1dd170bb45f0216c2cff15968f24 Mon Sep 17 00:00:00 2001
From: Ruoqing He <ruoqing@isrc.iscas.ac.cn>
Date: Mon, 29 Apr 2024 16:20:35 +0800
Subject: [PATCH] Add support for riscv64 platform
Signed-off-by: Ruoqing He <ruoqing@isrc.iscas.ac.cn>
---
src/agent/src/linux_abi.rs | 3 +-
src/runtime/Makefile | 3 +
src/runtime/arch/riscv64-options.mk | 13 ++
.../cmd/kata-runtime/kata-check_riscv64.go | 130 ++++++++++++++++++
src/runtime/pkg/govmm/vmm_riscv64.go | 12 ++
.../factory/template/template_riscv64.go | 14 ++
.../virtcontainers/hypervisor_riscv64.go | 11 ++
src/runtime/virtcontainers/qemu_riscv64.go | 68 +++++++++
8 files changed, 253 insertions(+), 1 deletion(-)
create mode 100644 src/runtime/arch/riscv64-options.mk
create mode 100644 src/runtime/cmd/kata-runtime/kata-check_riscv64.go
create mode 100644 src/runtime/pkg/govmm/vmm_riscv64.go
create mode 100644 src/runtime/virtcontainers/factory/template/template_riscv64.go
create mode 100644 src/runtime/virtcontainers/hypervisor_riscv64.go
create mode 100644 src/runtime/virtcontainers/qemu_riscv64.go
diff --git a/src/agent/src/linux_abi.rs b/src/agent/src/linux_abi.rs
index b87da3c..fdb70be 100644
--- a/src/agent/src/linux_abi.rs
+++ b/src/agent/src/linux_abi.rs
@@ -15,7 +15,8 @@ pub const SYSFS_DIR: &str = "/sys";
target_arch = "powerpc64",
target_arch = "s390x",
target_arch = "x86_64",
- target_arch = "x86"
+ target_arch = "x86",
+ target_arch = "riscv64"
))]
pub fn create_pci_root_bus_path() -> String {
String::from("/devices/pci0000:00")
diff --git a/src/runtime/Makefile b/src/runtime/Makefile
index 33fa8f2..977dbfc 100644
--- a/src/runtime/Makefile
+++ b/src/runtime/Makefile
@@ -22,6 +22,9 @@ endif
ifeq ($(ARCH),aarch64)
override ARCH = arm64
endif
+ifeq ($(ARCH),riscv64)
+ override ARCH = riscv64
+endif
ARCH_DIR = arch
ARCH_FILE_SUFFIX = -options.mk
diff --git a/src/runtime/arch/riscv64-options.mk b/src/runtime/arch/riscv64-options.mk
new file mode 100644
index 0000000..91eef18
--- /dev/null
+++ b/src/runtime/arch/riscv64-options.mk
@@ -0,0 +1,13 @@
+# Copyright (c) 2023 Xin Liu
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+# riscv64 settings
+
+MACHINETYPE := virt
+KERNELPARAMS :=
+MACHINEACCELERATORS :=
+CPUFEATURES :=
+
+QEMUCMD := qemu-system-riscv64
diff --git a/src/runtime/cmd/kata-runtime/kata-check_riscv64.go b/src/runtime/cmd/kata-runtime/kata-check_riscv64.go
new file mode 100644
index 0000000..a16f869
--- /dev/null
+++ b/src/runtime/cmd/kata-runtime/kata-check_riscv64.go
@@ -0,0 +1,130 @@
+// Copyright (c) 2018 Intel Corporation
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+
+package main
+
+import (
+ "fmt"
+ "strings"
+
+ vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
+ "github.com/sirupsen/logrus"
+)
+
+const (
+ cpuFlagsTag = genericCPUFlagsTag
+ archCPUVendorField = "uarch"
+ archCPUModelField = "isa"
+)
+
+// archRequiredCPUFlags maps a CPU flag value to search for and a
+// human-readable description of that value.
+var archRequiredCPUFlags = map[string]string{}
+
+// archRequiredCPUAttribs maps a CPU (non-CPU flag) attribute value to search for
+// and a human-readable description of that value.
+var archRequiredCPUAttribs = map[string]string{}
+
+// archRequiredKernelModules maps a required module name to a human-readable
+// description of the modules functionality and an optional list of
+// required module parameters.
+var archRequiredKernelModules = map[string]kernelModule{
+ "kvm": {
+ desc: "Kernel-based Virtual Machine",
+ required: true,
+ },
+ "vhost_vsock": {
+ desc: "Host Support for Linux VM Sockets",
+ required: false,
+ },
+}
+
+func setCPUtype(hypervisorType vc.HypervisorType) error {
+ return nil
+}
+
+// kvmIsUsable determines if it will be possible to create a full virtual machine
+// by creating a minimal VM and then deleting it.
+func kvmIsUsable() error {
+ return genericKvmIsUsable()
+}
+
+func archHostCanCreateVMContainer(hypervisorType vc.HypervisorType) error {
+ return kvmIsUsable()
+}
+
+// hostIsVMContainerCapable checks to see if the host is theoretically capable
+// of creating a VM container.
+func hostIsVMContainerCapable(details vmContainerCapableDetails) error {
+
+ _, err := getCPUInfo(details.cpuInfoFile)
+ if err != nil {
+ return err
+ }
+
+ count, err := checkKernelModules(details.requiredKernelModules, archKernelParamHandler)
+ if err != nil {
+ return err
+ }
+
+ if count == 0 {
+ return nil
+ }
+
+ return fmt.Errorf("ERROR: %s", failMessage)
+
+}
+
+func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool {
+ return genericArchKernelParamHandler(onVMM, fields, msg)
+}
+
+func getRiscv64CPUDetails() (vendor, model string, err error) {
+ prefixModel := "processor"
+ cpuinfo, err := getCPUInfo(procCPUInfo)
+ if err != nil {
+ return "", "", err
+ }
+
+ lines := strings.Split(cpuinfo, "\n")
+
+ for _, line := range lines {
+ if archCPUVendorField != "" {
+ if strings.HasPrefix(line, archCPUVendorField) {
+ fields := strings.Split(line, ":")
+ if len(fields) > 1 {
+ vendor = strings.TrimSpace(fields[1])
+ }
+ }
+ } else {
+ vendor = "Unknown"
+ }
+ if archCPUModelField != "" {
+ if strings.HasPrefix(line, prefixModel) {
+ fields := strings.Split(line, ":")
+ if len(fields) > 1 {
+ model = strings.TrimSpace(fields[1])
+ }
+ }
+ }
+ }
+
+ if vendor == "" {
+ return "", "", fmt.Errorf("cannot find vendor field in file %v", procCPUInfo)
+ }
+
+ if model == "" {
+ return "", "", fmt.Errorf("Error in parsing cpu model from %v", procCPUInfo)
+ }
+
+ return vendor, model, nil
+}
+
+func getCPUDetails() (string, string, error) {
+ if vendor, model, err := genericGetCPUDetails(); err == nil {
+ return vendor, model, nil
+ }
+ return getRiscv64CPUDetails()
+}
diff --git a/src/runtime/pkg/govmm/vmm_riscv64.go b/src/runtime/pkg/govmm/vmm_riscv64.go
new file mode 100644
index 0000000..5ea2e94
--- /dev/null
+++ b/src/runtime/pkg/govmm/vmm_riscv64.go
@@ -0,0 +1,12 @@
+//
+// Copyright (c) 2018 Intel Corporation
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+
+package govmm
+
+// MaxVCPUs returns the maximum number of vCPUs supported
+func MaxVCPUs() uint32 {
+ return uint32(512)
+}
diff --git a/src/runtime/virtcontainers/factory/template/template_riscv64.go b/src/runtime/virtcontainers/factory/template/template_riscv64.go
new file mode 100644
index 0000000..abb639b
--- /dev/null
+++ b/src/runtime/virtcontainers/factory/template/template_riscv64.go
@@ -0,0 +1,14 @@
+// Copyright (c) 2023 Xin Liu
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+// template implements base vm factory with vm templating.
+
+package template
+
+// templateDeviceStateSize denotes device state size when
+// mount tmpfs.
+// when bypass-shared-memory is not support like arm64,
+// creating template will occupy more space. That's why we
+// put it here.
+const templateDeviceStateSize = 8
diff --git a/src/runtime/virtcontainers/hypervisor_riscv64.go b/src/runtime/virtcontainers/hypervisor_riscv64.go
new file mode 100644
index 0000000..78d128f
--- /dev/null
+++ b/src/runtime/virtcontainers/hypervisor_riscv64.go
@@ -0,0 +1,11 @@
+// Copyright (c) 2021 Arm Ltd.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package virtcontainers
+
+// Guest protection is not supported on RISCV64.
+func availableGuestProtection() (guestProtection, error) {
+ return noneProtection, nil
+}
+
diff --git a/src/runtime/virtcontainers/qemu_riscv64.go b/src/runtime/virtcontainers/qemu_riscv64.go
new file mode 100644
index 0000000..846a5f2
--- /dev/null
+++ b/src/runtime/virtcontainers/qemu_riscv64.go
@@ -0,0 +1,68 @@
+// Copyright (c) 2023 Xin Liu
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+
+package virtcontainers
+
+import (
+ "fmt"
+ "time"
+
+ govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
+)
+
+type qemuRiscv64 struct {
+ // inherit from qemuArchBase, overwrite methods if needed
+ qemuArchBase
+}
+
+const defaultQemuPath = "/usr/bin/qemu-system-riscv64"
+
+const defaultQemuMachineType = QemuVirt
+
+const qmpMigrationWaitTimeout = 10 * time.Second
+
+const defaultQemuMachineOptions = ""
+
+var defaultGICVersion = uint32(3)
+
+var kernelParams = []Param{
+ {"numa", "off"},
+}
+
+var supportedQemuMachine = govmmQemu.Machine{
+ Type: QemuVirt,
+ Options: defaultQemuMachineOptions,
+}
+
+// MaxQemuVCPUs returns the maximum number of vCPUs supported
+func MaxQemuVCPUs() uint32 {
+ return uint32(512)
+}
+
+func newQemuArch(config HypervisorConfig) (qemuArch, error) {
+ machineType := config.HypervisorMachineType
+ if machineType == "" {
+ machineType = defaultQemuMachineType
+ }
+
+ if machineType != defaultQemuMachineType {
+ return nil, fmt.Errorf("unrecognised machinetype: %v", machineType)
+ }
+
+ q := &qemuRiscv64{
+ qemuArchBase{
+ qemuMachine: supportedQemuMachine,
+ qemuExePath: defaultQemuPath,
+ memoryOffset: config.MemOffset,
+ kernelParamsNonDebug: kernelParamsNonDebug,
+ kernelParamsDebug: kernelParamsDebug,
+ kernelParams: kernelParams,
+ },
+ }
+
+ q.handleImagePath(config)
+
+ return q, nil
+}
--
2.43.0

7
series.conf Normal file
View File

@ -0,0 +1,7 @@
0001-virtcontainers-Add-StratoVirt-as-a-supported-hypervi.patch
0002-build-Makefile-for-StratoVirt-hypervisor.patch
0003-configuration-add-configuration-for-StratoVirt-hyper.patch
0004-kata-deploy-Add-StratoVirt-support-to-deploy-process.patch
0005-mount-Reduce-the-mount-points-with-namespace-isolati.patch
0006-Allow-swappiness-to-be-1-as-default.patch
0007-Add-support-for-riscv64-platform.patch

18
version.rs Normal file
View File

@ -0,0 +1,18 @@
// Copyright (c) 2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
//
// WARNING: This file is auto-generated - DO NOT EDIT!
//
#![allow(dead_code)]
pub const AGENT_VERSION: &str = "3.2.0";
pub const API_VERSION: &str = "0.0.1";
pub const VERSION_COMMIT: &str = "3.2.0-15e85b8ce740faf026e7d72d0d950cd9e0bbfc1d";
pub const GIT_COMMIT: &str = "15e85b8ce740faf026e7d72d0d950cd9e0bbfc1d";
pub const AGENT_NAME: &str = "kata-agent";
pub const AGENT_DIR: &str = "/usr/bin";
pub const AGENT_PATH: &str = "/usr/bin/kata-agent";