From e2e5971ae5d38f155cdf7293ed261395eaaea149 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Wed, 4 Oct 2023 09:49:11 -0300 Subject: [PATCH] Test hypervisor bug --- src/hp-test/Makefile | 34 ++++++++++++++++ src/hp-test/guest-rootfs.Dockerfile | 30 ++++++++++++++ src/hp-test/host-rootfs.Dockerfile | 62 +++++++++++++++++++++++++++++ src/hp-test/kvmtool-net-exit.patch | 12 ++++++ src/hp-test/lkvm-test.sh | 16 ++++++++ 5 files changed, 154 insertions(+) create mode 100644 src/hp-test/Makefile create mode 100644 src/hp-test/guest-rootfs.Dockerfile create mode 100644 src/hp-test/host-rootfs.Dockerfile create mode 100644 src/hp-test/kvmtool-net-exit.patch create mode 100644 src/hp-test/lkvm-test.sh diff --git a/src/hp-test/Makefile b/src/hp-test/Makefile new file mode 100644 index 000000000..db85e78ab --- /dev/null +++ b/src/hp-test/Makefile @@ -0,0 +1,34 @@ +CARTESI_MACHINE=lua ../cartesi-machine.lua + +all: host-rootfs.ext2 guest-rootfs.ext2 + +%.ext2: %.gnutar + genext2fs --faketime --block-size 4096 --readjustment +0 --tarball $< $@ + +%.gnutar: %.tar + bsdtar -cf $@ --format=gnutar @$< + +host-rootfs.tar: host-rootfs.Dockerfile guest-linux.bin lkvm-test.sh +%.tar: %.Dockerfile + docker build --platform=linux/riscv64 --file $< --output type=tar,dest=$@ --progress plain . + +clean: + rm -f *.ext2 *.tar *.gnutar + +shell: + $(CARTESI_MACHINE) \ + --ram-image=host-linux.bin \ + --flash-drive=label:root,filename:host-rootfs.ext2 \ + --flash-drive=label:guest-root,filename:guest-rootfs.ext2 \ + --ram-length=1024Mi \ + -i bash + +test: + $(CARTESI_MACHINE) \ + --ram-image=host-linux.bin \ + --flash-drive=label:root,filename:host-rootfs.ext2 \ + --flash-drive=label:guest-root,filename:guest-rootfs.ext2 \ + --ram-length=1024Mi \ + /root/lkvm-test.sh + +.PHONY: clean shell test diff --git a/src/hp-test/guest-rootfs.Dockerfile b/src/hp-test/guest-rootfs.Dockerfile new file mode 100644 index 000000000..d59ccafdc --- /dev/null +++ b/src/hp-test/guest-rootfs.Dockerfile @@ -0,0 +1,30 @@ +# syntax=docker.io/docker/dockerfile:1.4 +FROM --platform=linux/riscv64 riscv64/ubuntu:22.04 + +# Update system +RUN <downscript, ndev->tap_name); + + list_del(&ndev->list); ++ ndev->vdev.ops->exit(kvm, &ndev->vdev); + free(ndev); + } + return 0; diff --git a/src/hp-test/lkvm-test.sh b/src/hp-test/lkvm-test.sh new file mode 100644 index 000000000..d0705b577 --- /dev/null +++ b/src/hp-test/lkvm-test.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e +insmod kvm.ko + +while true; do +lkvm run \ +--network virtio \ +--disk /dev/mtdblock1 \ +--kernel guest-linux.bin \ +--virtio-transport mmio \ +--params "\ +init=/opt/cartesi/bin/init loglevel=5 splash=no single=yes \ +-- \ +busybox ip link set dev eth0 up && +echo booted" +done