From ee06f73edf73acf767a4a1d8f0e9a5d5b2427da4 Mon Sep 17 00:00:00 2001 From: T H Date: Mon, 9 Feb 2026 20:25:26 +0800 Subject: [PATCH 1/4] Enhance VM setup documentation with detailed instructions Updated network configuration instructions and added disk configuration steps for setting up a virtual machine environment. Signed-off-by: Teng Huang --- HelloWorldExample.md | 82 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 HelloWorldExample.md diff --git a/HelloWorldExample.md b/HelloWorldExample.md new file mode 100644 index 00000000..6de5e4eb --- /dev/null +++ b/HelloWorldExample.md @@ -0,0 +1,82 @@ +# Run Ping in vmm-reference + +## 1. Host Configuration + +### 1.1 Network Configuration +```bash +sudo ip tuntap add dev tap0 mode tap +sudo ip addr add 192.168.100.1/24 dev tap0 +sudo ip link set tap0 up + +sudo sysctl -w net.ipv4.ip_forward=1 +sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # replace eth0 to your network interface (run "ip a" to list all interface ), for example: wlp3s0 +sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT +sudo iptables -A FORWARD -i tap0 -o eth0 -j ACCEPT +``` + +### 1.2 Disk Configuration +```bash +dd if=/dev/zero of=rootfs.ext4 bs=1M count=128 +mkfs.ext4 rootfs.ext4 +mkdir -p ./mnt +sudo mount -o loop rootfs.ext4 ./mnt + +curl -O https://busybox.net/downloads/busybox-1.37.0.tar.bz2 +tar xf busybox-1.37.0.tar.bz2 +cd busybox-1.37.0 +make menuconfig +# select the option: "Settings -> Build static binary (no shared libs)" +make install + +cd .. +sudo cp -a ./busybox-1.37.0/_install/* ./mnt/ + +sudo tee ./mnt/init.sh << 'EOF' +#!/bin/sh +set -eux + +mkdir -p /proc /sys /dev + +mount -t proc none /proc +mount -t sysfs none /sys +mount -t devtmpfs none /dev + +echo "[init] bring up network" + +ip a + +ip link set lo up +ip link set eth0 up +ip addr add 192.168.100.2/24 dev eth0 +ip route add default via 192.168.100.1 + +echo "[init] start ping" +ping 8.8.8.8 -c 4 + +echo "[init] ping finished, poweroff" +poweroff -f +EOF + +sudo chmod +x ./mnt/init.sh + +sudo umount ./mnt +``` + +## 2. Guest Configuration + +```bash +wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.1.tar.xz +tar xf linux-5.10.1.tar.xz + +wget https://github.com/firecracker-microvm/firecracker/blob/main/resources/guest_configs/microvm-kernel-ci-x86_64-5.10.config +cp microvm-kernel-ci-x86_64-5.10.config linux-5.10.1/.config + +cd linux-5.10.1 +make oldconfig +make vmlinux -j 4 +``` + +## 3、Run +```bash +sudo rust-vmm/vmm-reference/target/debug/vmm-reference --kernel path=./linux-5.10.1/vmlinux,cmdline="root=/dev/vda rw init=/init.sh" --block path=rootfs.ext4 --net tap=tap0 +``` From ac32ebc16c2dcc8163c7e9b74bb678b6073c2f50 Mon Sep 17 00:00:00 2001 From: T H Date: Mon, 9 Feb 2026 20:26:40 +0800 Subject: [PATCH 2/4] Update build instructions in HelloWorldExample.md Added a missing command to the build instructions. Signed-off-by: Teng Huang --- HelloWorldExample.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HelloWorldExample.md b/HelloWorldExample.md index 6de5e4eb..02ca9b5e 100644 --- a/HelloWorldExample.md +++ b/HelloWorldExample.md @@ -74,6 +74,8 @@ cp microvm-kernel-ci-x86_64-5.10.config linux-5.10.1/.config cd linux-5.10.1 make oldconfig make vmlinux -j 4 + +cd .. ``` ## 3、Run From b97683efd287bb273e4bce20dfb929f7ce53e172 Mon Sep 17 00:00:00 2001 From: T H Date: Mon, 9 Feb 2026 20:31:36 +0800 Subject: [PATCH 3/4] Include init.sh in HelloWorldExample.md Add init.sh script for initialization process Signed-off-by: Teng Huang --- HelloWorldExample.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HelloWorldExample.md b/HelloWorldExample.md index 02ca9b5e..0e757970 100644 --- a/HelloWorldExample.md +++ b/HelloWorldExample.md @@ -30,7 +30,9 @@ make install cd .. sudo cp -a ./busybox-1.37.0/_install/* ./mnt/ +``` +```bash sudo tee ./mnt/init.sh << 'EOF' #!/bin/sh set -eux @@ -56,7 +58,9 @@ ping 8.8.8.8 -c 4 echo "[init] ping finished, poweroff" poweroff -f EOF +``` +```bash sudo chmod +x ./mnt/init.sh sudo umount ./mnt From 471ff397ec42772bc3e25287556857d9ed96fa13 Mon Sep 17 00:00:00 2001 From: T H Date: Mon, 9 Feb 2026 20:35:35 +0800 Subject: [PATCH 4/4] Updated Signed-off-by: Teng Huang --- HelloWorldExample.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HelloWorldExample.md b/HelloWorldExample.md index 0e757970..958edbe3 100644 --- a/HelloWorldExample.md +++ b/HelloWorldExample.md @@ -82,7 +82,7 @@ make vmlinux -j 4 cd .. ``` -## 3、Run +## 3. Run ```bash sudo rust-vmm/vmm-reference/target/debug/vmm-reference --kernel path=./linux-5.10.1/vmlinux,cmdline="root=/dev/vda rw init=/init.sh" --block path=rootfs.ext4 --net tap=tap0 ```