Skip to content

PengJi/compute-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build a hypervisor based on KVM with Rust

目标: 有用 轻量低噪、软硬协同、安全

应用场景 特新需求 轻快灵活

Using the KVM API

kvmtools StratoVrit cloud-hypervisor firecracker kata-containers microvm in qemu

运行

准备 Linux 内核镜像

wget https://repo.openeuler.org/openEuler-22.03-LTS/stratovirt_img/x86_64/vmlinux.bin

准备 initrd 文件系统镜像

下载 busybox

wget https://busybox.net/downloads/busybox-1.36.1.tar.bz2
tar -xjf busybox-1.36.1.tar.bz2

编译 busybox

cd busybox-1.36.1
make defconfig
make menuconfig

配置

Settings  --->
    [*] Build static binary (no shared libs)

安装 busybox

make install

在当前目录下会生成一个 _install 目录,里面包含了 busybox 的可执行文件和一些必要的文件。

配置 busybox

cd _install
mkdir proc sys dev etc etc/init.d
touch etc/init.d/rcS

cat >etc/init.d/rcS<<EOF
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s
EOF

chmod +x etc/init.d/rcS

制作 ininrd 镜像

cd _install
find . | cpio -o --format=newc > /tmp/StratoVirt-initrd

生成 hypervisor

cargo build --release

运行

./target/release/stratovirt \
    -machine microvm \
    -kernel /tmp/vmlinux.bin\
    -append "console=ttyS0 reboot=k panic=1 root=/dev/ram rdinit=/bin/sh" \
    -initrd /tmp/StratoVirt-initrd \
    -qmp unix:./qmp.sock,server,nowait \
    -serial stdio

kvm-hello-world
OpenCloudOS/LiKeX
proj178-kvm-in-rust

About

Build a hypervisor with rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published