Build a hypervisor based on KVM with Rust
目标: 有用 轻量低噪、软硬协同、安全
应用场景 特新需求 轻快灵活
kvmtools StratoVrit cloud-hypervisor firecracker kata-containers microvm in qemu
wget https://repo.openeuler.org/openEuler-22.03-LTS/stratovirt_img/x86_64/vmlinux.bin
wget https://busybox.net/downloads/busybox-1.36.1.tar.bz2
tar -xjf busybox-1.36.1.tar.bz2
cd busybox-1.36.1
make defconfig
make menuconfig
配置
Settings --->
[*] Build static binary (no shared libs)
make install
在当前目录下会生成一个 _install 目录,里面包含了 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
cd _install
find . | cpio -o --format=newc > /tmp/StratoVirt-initrd
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