转换LFS仓库为普通仓库

This commit is contained in:
Jiayi Yin 2025-05-18 22:18:02 +00:00
commit aa2644e34d
18 changed files with 6701 additions and 0 deletions

36
README.en.md Normal file
View File

@ -0,0 +1,36 @@
# kuasar
#### Description
Kuasar is an efficient container runtime that provides cloud-native, all-scenario container solutions by supporting multiple sandbox techniques.
#### 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 @@
# kuasar
#### 介绍
Kuasar is an efficient container runtime that provides cloud-native, all-scenario container solutions by supporting multiple sandbox techniques.
#### 软件架构
软件架构说明
#### 安装教程
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/)

14
apply-patches Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
tar -xzvf kuasar-v1.0.0-vendor.tar.gz
cp -rf ./kuasar-v1.0.0-vensor/* ./
cat ./series.conf | while read line
do
if [[ $line == '' || $line =~ ^\s*# ]]; then
continue
fi
echo "====patch $line======"
patch -p1 -F1 -s < ./patch/$line
done

40
initrd/make-initrd-rpm.list Executable file
View File

@ -0,0 +1,40 @@
# 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
# runc
runc
# bash
bash

99
initrd/make_kuasar_initrd.sh Executable file
View File

@ -0,0 +1,99 @@
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2023. 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 kuasar initrd
script_dir="$(dirname $(readlink -f $0))"
rpmlist=${script_dir}/make-initrd-rpm.list
IMAGE_NAME=${IMAGE_NAME:-kuasar.initrd}
ROOTFS_DIR=${ROOTFS_DIR:-/tmp/kuasar-rootfs}
# 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 \
${ROOTFS_DIR}/etc
if [ ! -f "${script_dir}/vmm-task" ];then
echo "vmm-task doesn't exist!"
exit 1
fi
touch ${ROOTFS_DIR}/etc/resolv.conf
# busybox
cp /sbin/busybox ${ROOTFS_DIR}/sbin/
cp ${script_dir}/vmm-task ${ROOTFS_DIR}/init
# 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"))
echo array
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 /usr/bin/bash /usr/bin/runc)
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
cp ${ROOTFS_DIR}/usr/bin/bash ${ROOTFS_DIR}/bin/bash
(cd ${ROOTFS_DIR} && find . | cpio -H newc -o | gzip -9 ) > ${script_dir}/${IMAGE_NAME}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

BIN
kuasar-v1.0.0-vendor.tar.gz Normal file

Binary file not shown.

122
kuasar.spec Normal file
View File

@ -0,0 +1,122 @@
%global debug_package %{nil}
Name: kuasar
Version: 1.0.0
Release: 5
Summary: Kuasar is an efficient container runtime that supports multiple sandbox techniques.
License: Apache License 2.0
URL: https://github.com/kuasar-io/kuasar
Source0: kuasar-openeuler.tar.gz
Source1: kernel.tar.gz
BuildRequires: automake golang bc glibc-devel glibc-static busybox glib2-devel glib2 ipvsadm conntrack-tools nfs-utils bash gcc cmake gcc-c++
BuildRequires: patch elfutils-libelf-devel openssl-devel bison flex rust cargo rust-packaging libgcc dtc-devel runc
%define _cargo /usr/bin/env CARGO_HOME=.cargo /usr/bin/cargo
%define hypervisor qemu
%define localbindir /usr/local/bin
%define kuasarconfdir /var/lib/kuasar
%define kuasarbuilddir %{_builddir}/kuasar-%{version}/kuasar-openeuler
%description
Kuasar is an efficient container runtime that provides cloud-native, all-scenario container solutions by supporting multiple sandbox techniques.
%prep
%setup -T -c -a 0 -n kuasar-%{version}
%setup -T -c -a 1 -n kernel
cd %{kuasarbuilddir}
sh -x apply-patches
cd %{_builddir}/kernel
mv kernel linux
cd %{_builddir}/kernel/linux
%ifarch %{ix86} x86_64
cp %{kuasarbuilddir}/kernel-config/kuasar-openeuler-kernel-x86_64.config ./.config
%else
cp %{kuasarbuilddir}/kernel-config/kuasar-openeuler-kernel-aarch64.config ./.config
%endif
%build
# build vmm-sandboxer and vmm-task
cd %{kuasarbuilddir}
sed -i '$a\[build\]\nrustflags = \["-Clink-arg=-s", "-Clink-arg=-Wl,-z,relro,-z,now"]' ./vmm/sandbox/.cargo/config.toml
sed -i '$a\[build\]\nrustflags = \["-Clink-arg=-s", "-Clink-arg=-Wl,-z,relro,-z,now"]' ./vmm/task/.cargo/config.toml
HYPERVISOR=%{hypervisor} make bin/vmm-sandboxer
%ifarch %{ix86} x86_64
ARCH=x86_64 HYPERVISOR=%{hypervisor} make bin/vmm-task
%else
ARCH=aarch64 HYPERVISOR=%{hypervisor} make bin/vmm-task
%endif
# build initrd
cp %{kuasarbuilddir}/bin/vmm-task ./initrd
cd initrd && sh -x make_kuasar_initrd.sh
# build kernel
cd %{_builddir}/kernel/linux/
make olddefconfig
make %{?_smp_mflags}
%install
mkdir -p -m 750 %{buildroot}/%{kuasarconfdir}
%ifarch %{ix86} x86_64
install -p -m 750 -D %{_builddir}/kernel/linux/arch/x86/boot/bzImage %{buildroot}/%{kuasarconfdir}/vmlinux.bin
install -p -m 640 -D %{kuasarbuilddir}/vmm/sandbox/config_%{hypervisor}_x86_64.toml %{buildroot}/%{kuasarconfdir}/config.toml
%else
install -p -m 750 -D %{_builddir}/kernel/linux/arch/arm64/boot/Image %{buildroot}/%{kuasarconfdir}/vmlinux.bin
install -p -m 640 -D %{kuasarbuilddir}/vmm/sandbox/config_%{hypervisor}_aarch64.toml %{buildroot}/%{kuasarconfdir}/config.toml
%endif
install -p -m 750 -D %{kuasarbuilddir}/initrd/kuasar.initrd %{buildroot}/%{kuasarconfdir}/kuasar.initrd
install -p -m 750 -D %{kuasarbuilddir}/bin/vmm-sandboxer %{buildroot}/%{localbindir}/vmm-sandboxer
install -p -m 640 -D %{kuasarbuilddir}/vmm/service/kuasar-vmm.service %{buildroot}/%{_unitdir}/kuasar-vmm.service
install -p -m 640 -D %{kuasarbuilddir}/vmm/service/kuasar-vmm %{buildroot}/etc/sysconfig/kuasar-vmm
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%config(noreplace) %{_unitdir}/kuasar-vmm.service
%config(noreplace) /etc/sysconfig/kuasar-vmm
%{localbindir}/vmm-sandboxer
%{kuasarconfdir}/vmlinux.bin
%{kuasarconfdir}/kuasar.initrd
%config(noreplace) %{kuasarconfdir}/config.toml
%changelog
* Mon Jan 6 liuxu <liuxu156@huawei.com> -1.0.0-5
- logfix:print warn instead of error when dir not found.
* Fri Nov 29 liuxu <liuxu156@huawei.com> -1.0.0-4
- fix:use ttrpc-rust in vendor
* Thu Nov 28 liuxu <liuxu156@huawei.com> -1.0.0-3
- vmm:add ttrpc-rust to use vendor
* Mon Nov 4 liuxu <liuxu156@huawei.com> -1.0.0-2
- vmm:adapt qemu
* Wed Oct 23 liuxu <liuxu156@huawei.com> -1.0.0-1
- update to 1.0.0
* Tue Feb 6 jiangpengfei <jiangpengfei9@huawei.com> -0.1.0-6
- update build_require from docker-runc to runc
* Mon Sep 19 Vanient <xidanni1@huawei.com> -0.1.0-5
- set CONFIG_INITRAMFS_FILE_METADATA empty
* Mon Sep 4 flyflyflypeng <jiangpengfei9@huawei.com> -0.1.0-4
- remove ExecReload field in the systemd service file
* Fri Sep 1 Vanient <xidanni1@huawei.com> -0.1.0-3
- revert musl build -static-pie
* Tue Aug 29 Vanient <xiadanni1@huawei.com> - 0.1.0-2
- optimize compile options
* Thu Aug 24 Vanient <xiadanni1@huawei.com> - 0.1.0-1
- update to 0.1.0
* Tue Jul 18 2023 flyflyflypeng <jiangpengfei9@huawei.com> - 0.0.1-1
- init package

View File

@ -0,0 +1,51 @@
From 8ff987b291cbf284329777ddda89bdb9f118266b Mon Sep 17 00:00:00 2001
From: Vanient <xiadanni1@huawei.com>
Date: Thu, 24 Aug 2023 15:01:38 +0800
Subject: [PATCH] add toml to use vendor
Signed-off-by: Vanient <xiadanni1@huawei.com>
---
vmm/sandbox/.cargo/config.toml | 14 ++++++++++++++
vmm/task/.cargo/config.toml | 9 +++++++++
2 files changed, 23 insertions(+)
create mode 100644 vmm/sandbox/.cargo/config.toml
create mode 100644 vmm/task/.cargo/config.toml
diff --git a/vmm/sandbox/.cargo/config.toml b/vmm/sandbox/.cargo/config.toml
new file mode 100644
index 00000000..148c98af
--- /dev/null
+++ b/vmm/sandbox/.cargo/config.toml
@@ -0,0 +1,14 @@
+[source.crates-io]
+replace-with = "vendored-sources"
+
+[source."git+https://github.com/cloud-hypervisor/cloud-hypervisor.git"]
+git = "https://github.com/cloud-hypervisor/cloud-hypervisor.git"
+replace-with = "vendored-sources"
+
+[source."git+https://github.com/kuasar-io/rust-extensions.git"]
+git = "https://github.com/kuasar-io/rust-extensions.git"
+replace-with = "vendored-sources"
+
+[source.vendored-sources]
+directory = "vendor"
+
diff --git a/vmm/task/.cargo/config.toml b/vmm/task/.cargo/config.toml
new file mode 100644
index 00000000..c7f73e86
--- /dev/null
+++ b/vmm/task/.cargo/config.toml
@@ -0,0 +1,9 @@
+[source.crates-io]
+replace-with = "vendored-sources"
+
+[source."git+https://github.com/kuasar-io/rust-extensions.git"]
+git = "https://github.com/kuasar-io/rust-extensions.git"
+replace-with = "vendored-sources"
+
+[source.vendored-sources]
+directory = "vendor"
--
2.27.0

View File

@ -0,0 +1,25 @@
From c177b346550b8b0899bc4e701b3f3bb4e8d0fb73 Mon Sep 17 00:00:00 2001
From: flyflyflypeng <jiangpengfei9@huawei.com>
Date: Mon, 4 Sep 2023 10:33:07 +0800
Subject: [PATCH] [kuasar]: remove ExecReload field in the service file
Signed-off-by: flyflyflypeng <jiangpengfei9@huawei.com>
---
vmm/service/kuasar-vmm.service | 1 -
1 file changed, 1 deletion(-)
diff --git a/vmm/service/kuasar-vmm.service b/vmm/service/kuasar-vmm.service
index 7be315f..e99b6c9 100644
--- a/vmm/service/kuasar-vmm.service
+++ b/vmm/service/kuasar-vmm.service
@@ -6,7 +6,6 @@ After=network.target
Type=simple
EnvironmentFile=-/etc/sysconfig/kuasar-vmm
ExecStart=/usr/local/bin/vmm-sandboxer $OPTIONS
-ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
--
2.33.0

View File

@ -0,0 +1,26 @@
From 95072e53f6c196651ec1e1a642354ec7e9907a27 Mon Sep 17 00:00:00 2001
From: Vanient <xiadanni1@huawei.com>
Date: Tue, 19 Sep 2023 21:16:28 +0800
Subject: [PATCH] set CONFIG_INITRAMFS_FILE_METADATA empty
Signed-off-by: Vanient <xiadanni1@huawei.com>
---
.../kernel/stratovirt/kuasar-openeuler-kernel-aarch64.config | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vmm/scripts/kernel/stratovirt/kuasar-openeuler-kernel-aarch64.config b/vmm/scripts/kernel/stratovirt/kuasar-openeuler-kernel-aarch64.config
index cf2a58e7..28cd508f 100644
--- a/vmm/scripts/kernel/stratovirt/kuasar-openeuler-kernel-aarch64.config
+++ b/vmm/scripts/kernel/stratovirt/kuasar-openeuler-kernel-aarch64.config
@@ -186,7 +186,7 @@ CONFIG_RD_GZIP=y
# CONFIG_RD_LZO is not set
# CONFIG_RD_LZ4 is not set
CONFIG_RD_ZSTD=y
-CONFIG_INITRAMFS_FILE_METADATA="n"
+CONFIG_INITRAMFS_FILE_METADATA=""
# CONFIG_BOOT_CONFIG is not set
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
--
2.27.0

View File

@ -0,0 +1,75 @@
From 7f52dd3960ad30db7ac8f0eff3aa0f691c6dff38 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Wed, 23 Oct 2024 16:47:26 +0800
Subject: [PATCH] vmm:qemu support aarch64
Signed-off-by: liuxu <liuxu156@huawei.com>
---
vmm/sandbox/src/qemu/config.rs | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/vmm/sandbox/src/qemu/config.rs b/vmm/sandbox/src/qemu/config.rs
index ce2df24..bf3c986 100644
--- a/vmm/sandbox/src/qemu/config.rs
+++ b/vmm/sandbox/src/qemu/config.rs
@@ -21,7 +21,6 @@ use std::{
};
use containerd_sandbox::error::{Error, Result};
-#[cfg(target_arch = "x86_64")]
use lazy_static::lazy_static;
use sandbox_derive::{CmdLineParamSet, CmdLineParams};
use serde::{Deserialize, Serialize};
@@ -40,22 +39,23 @@ const DEFAULT_QEMU_PATH: &str = "/usr/bin/qemu-system-x86_64";
#[cfg(target_arch = "aarch64")]
const DEFAULT_QEMU_PATH: &str = "/usr/bin/qemu-system-aarch64";
-#[cfg(target_arch = "x86_64")]
lazy_static! {
static ref SUPPORTED_MACHINES: HashMap<String, Machine> = {
let mut sms = HashMap::new();
+ #[cfg(target_arch = "x86_64")]
sms.insert(
- "microvm-pci".to_string(),
+ "pc".to_string(),
Machine {
- r#type: "microvm-pci".to_string(),
- options: None,
+ r#type: "pc".to_string(),
+ options: Some("accel=kvm,kernel_irqchip=on".to_string()),
},
);
+ #[cfg(target_arch = "aarch64")]
sms.insert(
- "pc".to_string(),
+ "virt".to_string(),
Machine {
- r#type: "pc".to_string(),
- options: Some("accel=kvm,kernel_irqchip=on".to_string()),
+ r#type: "virt".to_string(),
+ options: Some("usb=off,accel=kvm,gic-version=3".to_string()),
},
);
sms
@@ -155,7 +155,6 @@ impl QemuVMConfig {
} else {
return Err(Error::InvalidArgument("cpu model".to_string()));
}
- #[cfg(target_arch = "x86_64")]
if let Some(machine) = SUPPORTED_MACHINES.get(&self.machine_type) {
result.machine = machine.clone();
} else {
@@ -163,10 +162,6 @@ impl QemuVMConfig {
"machine_type not supported!".to_string(),
));
}
- #[cfg(not(target_arch = "x86_64"))]
- return Err(Error::Unimplemented(
- "cpu other than x86 not supported".to_string(),
- ));
if !self.firmware_path.is_empty() {
result.bios = Some(self.firmware_path.to_string());
}
--
2.43.0

View File

@ -0,0 +1,217 @@
From 753b9dc20b825a08ecad8d7e00da451153354f00 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Fri, 25 Oct 2024 17:25:19 +0800
Subject: [PATCH] vmm:qemu support config_qemu.toml
Signed-off-by: liuxu <liuxu156@huawei.com>
---
Makefile | 18 +++++++------
vmm/sandbox/config_qemu_aarch64.toml | 38 ++++++++++++++++++++++++++++
vmm/sandbox/config_qemu_x86_64.toml | 38 ++++++++++++++++++++++++++++
vmm/sandbox/src/args.rs | 6 ++---
vmm/sandbox/src/bin/qemu/main.rs | 8 +++---
vmm/sandbox/src/qemu/config.rs | 1 +
6 files changed, 95 insertions(+), 14 deletions(-)
create mode 100644 vmm/sandbox/config_qemu_aarch64.toml
create mode 100644 vmm/sandbox/config_qemu_x86_64.toml
diff --git a/Makefile b/Makefile
index 60b3273..a6fff58 100644
--- a/Makefile
+++ b/Makefile
@@ -52,10 +52,11 @@ wasm: bin/wasm-sandboxer
quark: bin/quark-sandboxer
runc: bin/runc-sandboxer
-ifeq ($(HYPERVISOR), stratovirt)
-vmm: bin/vmm-sandboxer bin/kuasar.initrd bin/vmlinux.bin
-else
+ifeq ($(HYPERVISOR), cloud_hypervisor)
vmm: bin/vmm-sandboxer bin/kuasar.img bin/vmlinux.bin
+else
+# stratovirt or qemu
+vmm: bin/vmm-sandboxer bin/kuasar.initrd bin/vmlinux.bin
endif
clean:
@@ -76,12 +77,13 @@ install-vmm:
@install -d -m 750 ${DEST_DIR}${SYSTEMD_CONF_DIR}
@install -p -m 640 vmm/service/kuasar-vmm ${DEST_DIR}${SYSTEMD_CONF_DIR}/kuasar-vmm
-ifeq ($(HYPERVISOR), stratovirt)
- @install -p -m 640 bin/kuasar.initrd ${DEST_DIR}${INSTALL_DIR}/kuasar.initrd
- @install -p -m 640 vmm/sandbox/config_stratovirt_${ARCH}.toml ${DEST_DIR}${INSTALL_DIR}/config_stratovirt.toml
-else
+ifeq ($(HYPERVISOR), cloud_hypervisor)
@install -p -m 640 bin/kuasar.img ${DEST_DIR}${INSTALL_DIR}/kuasar.img
- @install -p -m 640 vmm/sandbox/config_clh.toml ${DEST_DIR}${INSTALL_DIR}/config_clh.toml
+ @install -p -m 640 vmm/sandbox/config_clh.toml ${DEST_DIR}${INSTALL_DIR}/config.toml
+else
+# stratovirt or qemu
+ @install -p -m 640 bin/kuasar.initrd ${DEST_DIR}${INSTALL_DIR}/kuasar.initrd
+ @install -p -m 640 vmm/sandbox/config_${HYPERVISOR}_${ARCH}.toml ${DEST_DIR}${INSTALL_DIR}/config.toml
endif
install-wasm:
diff --git a/vmm/sandbox/config_qemu_aarch64.toml b/vmm/sandbox/config_qemu_aarch64.toml
new file mode 100644
index 0000000..c4608e0
--- /dev/null
+++ b/vmm/sandbox/config_qemu_aarch64.toml
@@ -0,0 +1,38 @@
+[sandbox]
+log_level = "info"
+
+[hypervisor]
+memory_in_mb = 2048
+vcpus = 1
+kernel_params = "task.log_level=debug task.sharefs_type=9p tsc=reliable rcupdate.rcu_expedited=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1 noreplace-smp= reboot=k console=hvc0 console=hvc1 iommu=off cryptomgr.notests= net.ifnames=0 pci=lastbus=0"
+kernel_path = "/var/lib/kuasar/vmlinux.bin"
+initrd_path = "/var/lib/kuasar/kuasar.initrd"
+machine_accelerators = ""
+firmware_path = ""
+cpu_features = "pmu=off"
+cpu_model = "host"
+qemu_path = "/usr/bin/qemu-system-aarch64"
+machine_type = "virt"
+default_bridges = 1
+default_max_vcpus = 0
+entropy_source = "/dev/urandom"
+mem_slots = 1
+mem_offset = 0
+memory_path = ""
+file_backend_mem_path = ""
+mem_prealloc = false
+hugepages = false
+enable_vhost_user_store = false
+enable_swap = false
+virtiofs_daemon_path = "/usr/libexec/virtiofsd"
+virtiofs_cache = "auto"
+virtiofs_extra_args = ["--thread-pool-size=1", "--announce-submounts"]
+virtiofs_cache_size = 0
+msize_9p = 8192
+virtio_9p_direct_io = false
+virtio_9p_multidevs = ""
+enable_iothreads = false
+block_device_driver = "VirtioScsi"
+disable_nvdimm = true
+share_fs = "Virtio9P"
+use_vsock = true
diff --git a/vmm/sandbox/config_qemu_x86_64.toml b/vmm/sandbox/config_qemu_x86_64.toml
new file mode 100644
index 0000000..340f694
--- /dev/null
+++ b/vmm/sandbox/config_qemu_x86_64.toml
@@ -0,0 +1,38 @@
+[sandbox]
+log_level = "info"
+
+[hypervisor]
+memory_in_mb = 2048
+vcpus = 1
+kernel_params = "task.log_level=debug task.sharefs_type=9p tsc=reliable rcupdate.rcu_expedited=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1 noreplace-smp= reboot=k console=hvc0 console=hvc1 iommu=off cryptomgr.notests= net.ifnames=0 pci=lastbus=0"
+kernel_path = "/var/lib/kuasar/vmlinux.bin"
+initrd_path = "/var/lib/kuasar/kuasar.initrd"
+machine_accelerators = ""
+firmware_path = ""
+cpu_features = ""
+cpu_model = "host"
+qemu_path = "/usr/bin/qemu-system-x86_64"
+machine_type = "pc"
+default_bridges = 1
+default_max_vcpus = 0
+entropy_source = "/dev/urandom"
+mem_slots = 1
+mem_offset = 0
+memory_path = ""
+file_backend_mem_path = ""
+mem_prealloc = false
+hugepages = false
+enable_vhost_user_store = false
+enable_swap = false
+virtiofs_daemon_path = "/usr/bin/virtiofsd"
+virtiofs_cache = "always"
+virtiofs_extra_args = []
+virtiofs_cache_size = 1024
+msize_9p = 8192
+virtio_9p_direct_io = false
+virtio_9p_multidevs = ""
+enable_iothreads = false
+block_device_driver = "VirtioBlk"
+disable_nvdimm = true
+share_fs = "Virtio9P"
+use_vsock = true
diff --git a/vmm/sandbox/src/args.rs b/vmm/sandbox/src/args.rs
index 72e74d3..d6262dc 100644
--- a/vmm/sandbox/src/args.rs
+++ b/vmm/sandbox/src/args.rs
@@ -22,12 +22,12 @@ pub struct Args {
#[arg(short, long)]
pub version: bool,
- /// Config file path, only for cloud hypervisor and stratovirt, default is `/var/lib/kuasar/config_clh.toml`
+ /// Config file path, for cloud hypervisor, qemu and stratovirt, default is `/var/lib/kuasar/config.toml`
#[arg(
short,
long,
value_name = "FILE",
- default_value = "/var/lib/kuasar/config_clh.toml"
+ default_value = "/var/lib/kuasar/config.toml"
)]
pub config: String,
@@ -61,7 +61,7 @@ mod tests {
fn test_args_parse_default() {
let args = Args::parse();
assert!(!args.version);
- assert_eq!(args.config, "/var/lib/kuasar/config_clh.toml");
+ assert_eq!(args.config, "/var/lib/kuasar/config.toml");
assert_eq!(args.dir, "/run/kuasar-vmm");
assert_eq!(args.listen, "/run/vmm-sandboxer.sock");
assert!(args.log_level.is_none());
diff --git a/vmm/sandbox/src/bin/qemu/main.rs b/vmm/sandbox/src/bin/qemu/main.rs
index 4d76f9e..8edb32a 100644
--- a/vmm/sandbox/src/bin/qemu/main.rs
+++ b/vmm/sandbox/src/bin/qemu/main.rs
@@ -34,8 +34,7 @@ async fn main() {
}
// For compatibility with kata config
- let config_path = std::env::var("KATA_CONFIG_PATH")
- .unwrap_or_else(|_| "/usr/share/defaults/kata-containers/configuration.toml".to_string());
+ let config_path = std::env::var("KATA_CONFIG_PATH").unwrap_or_default();
let path = std::path::Path::new(&config_path);
let config = if path.exists() {
@@ -54,12 +53,15 @@ async fn main() {
// Initialize log
init_logger(&config.sandbox.log_level());
- let sandboxer: KuasarSandboxer<QemuVMFactory, QemuHooks> = KuasarSandboxer::new(
+ let mut sandboxer: KuasarSandboxer<QemuVMFactory, QemuHooks> = KuasarSandboxer::new(
config.sandbox,
config.hypervisor.clone(),
QemuHooks::new(config.hypervisor),
);
+ // Do recovery job
+ sandboxer.recover(&args.dir).await;
+
// Run the sandboxer
containerd_sandbox::run(
"kuasar-vmm-sandboxer-qemu",
diff --git a/vmm/sandbox/src/qemu/config.rs b/vmm/sandbox/src/qemu/config.rs
index bf3c986..408a39b 100644
--- a/vmm/sandbox/src/qemu/config.rs
+++ b/vmm/sandbox/src/qemu/config.rs
@@ -64,6 +64,7 @@ lazy_static! {
#[derive(Clone, Debug, Deserialize)]
pub struct QemuVMConfig {
+ #[serde(flatten)]
pub common: HypervisorCommonConfig,
pub machine_accelerators: String,
pub firmware_path: String,
--
2.43.0

View File

@ -0,0 +1,43 @@
From 726d90c0e9487273f556a1422a37f6b65e75b2d8 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Thu, 28 Nov 2024 21:24:11 +0800
Subject: [PATCH] add ttrpc-rust to use vendor
Signed-off-by: liuxu <liuxu156@huawei.com>
---
vmm/sandbox/.cargo/config.toml | 4 ++++
vmm/task/.cargo/config.toml | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/vmm/sandbox/.cargo/config.toml b/vmm/sandbox/.cargo/config.toml
index 148c98af..0740e49a 100644
--- a/vmm/sandbox/.cargo/config.toml
+++ b/vmm/sandbox/.cargo/config.toml
@@ -9,6 +9,10 @@ replace-with = "vendored-sources"
git = "https://github.com/kuasar-io/rust-extensions.git"
replace-with = "vendored-sources"
+[source."git+https://github.com/kuasar-io/ttrpc-rust.git"]
+git = "https://github.com/kuasar-io/ttrpc-rust.git"
+replace-with = "vendored-sources"
+
[source.vendored-sources]
directory = "vendor"
diff --git a/vmm/task/.cargo/config.toml b/vmm/task/.cargo/config.toml
index c7f73e86..906faaac 100644
--- a/vmm/task/.cargo/config.toml
+++ b/vmm/task/.cargo/config.toml
@@ -5,5 +5,9 @@ replace-with = "vendored-sources"
git = "https://github.com/kuasar-io/rust-extensions.git"
replace-with = "vendored-sources"
+[source."git+https://github.com/kuasar-io/ttrpc-rust.git"]
+git = "https://github.com/kuasar-io/ttrpc-rust.git"
+replace-with = "vendored-sources"
+
[source.vendored-sources]
directory = "vendor"
--
2.43.0

View File

@ -0,0 +1,38 @@
From 0c30ae1530c030aace0970cf7cfd8e636e9917d7 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Fri, 29 Nov 2024 16:27:40 +0800
Subject: [PATCH] fix:use ttrpc-rust in vendor
Signed-off-by: liuxu <liuxu156@huawei.com>
---
vmm/sandbox/.cargo/config.toml | 1 +
vmm/task/.cargo/config.toml | 1 +
2 files changed, 2 insertions(+)
diff --git a/vmm/sandbox/.cargo/config.toml b/vmm/sandbox/.cargo/config.toml
index 0740e49a..ecf54e19 100644
--- a/vmm/sandbox/.cargo/config.toml
+++ b/vmm/sandbox/.cargo/config.toml
@@ -11,6 +11,7 @@ replace-with = "vendored-sources"
[source."git+https://github.com/kuasar-io/ttrpc-rust.git"]
git = "https://github.com/kuasar-io/ttrpc-rust.git"
+branch = "v0.7.1-kuasar"
replace-with = "vendored-sources"
[source.vendored-sources]
diff --git a/vmm/task/.cargo/config.toml b/vmm/task/.cargo/config.toml
index 906faaac..cea47423 100644
--- a/vmm/task/.cargo/config.toml
+++ b/vmm/task/.cargo/config.toml
@@ -7,6 +7,7 @@ replace-with = "vendored-sources"
[source."git+https://github.com/kuasar-io/ttrpc-rust.git"]
git = "https://github.com/kuasar-io/ttrpc-rust.git"
+branch = "v0.7.1-kuasar"
replace-with = "vendored-sources"
[source.vendored-sources]
--
2.43.0

View File

@ -0,0 +1,33 @@
From 70b4d5f2fae117b3ced3ce76d25ef61bb453be1d Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Tue, 17 Dec 2024 11:11:12 +0800
Subject: [PATCH] logfix:print warn instead of error when dir not found.
Signed-off-by: liuxu <liuxu156@huawei.com>
---
vmm/sandbox/src/sandbox.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/vmm/sandbox/src/sandbox.rs b/vmm/sandbox/src/sandbox.rs
index 42875a8..dd724c9 100644
--- a/vmm/sandbox/src/sandbox.rs
+++ b/vmm/sandbox/src/sandbox.rs
@@ -90,8 +90,13 @@ where
let mut subs = match tokio::fs::read_dir(dir).await {
Ok(subs) => subs,
Err(e) => {
- error!("FATAL! read working dir {} for recovery: {}", dir, e);
- return;
+ if e.kind() == ErrorKind::NotFound {
+ warn!("WARN! read working dir {} for recovery: {}", dir, e);
+ return;
+ } else {
+ error!("FATAL! read working dir {} for recovery: {}", dir, e);
+ return;
+ }
}
};
while let Some(entry) = subs.next_entry().await.unwrap() {
--
2.34.1

8
series.conf Normal file
View File

@ -0,0 +1,8 @@
0001-add-toml-to-use-vendor.patch
0002-remove-ExecReload-field-in-the-service-file.patch
0003-set-CONFIG_INITRAMFS_FILE_METADATA-empty.patch
0004-vmm-qemu-support-aarch64.patch
0005-vmm-qemu-support-config_qemu.toml.patch
0006-add-ttrpc-rust-to-use-vendor.patch
0007-fix-use-ttrpc-rust-in-vendor.patch
0008-logfix-print-warn-instead-of-error-when-dir-not-foun.patch