diff --git a/hypervisor.md b/hypervisor.md index 710c154c7..68d958fc0 100644 --- a/hypervisor.md +++ b/hypervisor.md @@ -127,3 +127,42 @@ $ ${CROSS_COMPILE}strip lkvm-static ``` The above commands will create `kvmtool/lkvm-static` that you need to copy to your host root file system. + +## kvmtool segfault reproduce + +The segfault bug does not reproduce each time the hypervisor lauches. The reproducibility depends on the delays in the code, e.g. executing `sleep` or putting more printfs influences the reproducibility. The usual reproducibility rate is around 13-16%. It is also important to mention that virtio driver should be used (`-n virtio`) to reproduce the issue. + +The issue reproduces by booting hypervisor with no command: +``` +/hp/lkvm-static run --kernel /hp/Image --console serial --params "console=ttyS0 earlycon=sbi" -n virtio -d /hp/rootfs-virt.ext2 -m 100M +``` + +To test issue fixes I crafted a script that executes the hypervisor 100 times and checks the output fot segfault. + +``` +#!/bin/sh + +SEG_FAULT_COUNT=0 +TOTAL_RUNS=100 +CURRENT_RUN=1 +FILE=.test_file + +while [ "$CURRENT_RUN" -le "$TOTAL_RUNS" ]; do + /hp/lkvm-static run --kernel /hp/Image --console serial --params "console=ttyS0 earlycon=sbi -- /benchmarks/sleep; dmesg" -d /hp/rootfs-virt.ext2 -n virtio -m 100M &> $FILE + segfault=$(cat $FILE | grep "Segmentation fault") + + if [ -z "$segfault" ]; then + echo "Run $CURRENT_RUN: No segmentation fault" + else + SEG_FAULT_COUNT=$((SEG_FAULT_COUNT + 1)) + cat $FILE + echo "Run $CURRENT_RUN: Segmentation fault" + fi + + CURRENT_RUN=$((CURRENT_RUN + 1)) +done + +rm $FILE + +echo "Total Segmentation Faults: $SEG_FAULT_COUNT out of $TOTAL_RUNS runs" +```