From c235cb62beefd03087e7cfc7f7f55f0c7c6601c9 Mon Sep 17 00:00:00 2001 From: Lena Date: Sat, 1 Aug 2026 00:00:00 +0000 Subject: Enter vmm A QEMU/KVM virtual machine manager in one POSIX shell script. Each VM is a directory of plain files under $VMMDIR, configured by a hand-edited KEY=VALUE file that is parsed rather than sourced, so nothing in it can inject a raw QEMU argument. Control is a QMP FIFO pair inside that directory, guarded by its permissions alone; nothing binds a TCP port. The tests are TAP without a framework and boot real guests where the host allows. --- tests/env | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/env (limited to 'tests/env') diff --git a/tests/env b/tests/env new file mode 100644 index 0000000..aa0ea9b --- /dev/null +++ b/tests/env @@ -0,0 +1,32 @@ +# Environment variables reach qemu and the timeout loops, so they are +# checked once for every verb rather than inside the one that uses them. + +"$VMM" create ev1 64M >/dev/null 2>&1 + +# A differently spelled VMMDIR must name the same VMs, or a live guest +# goes invisible and the next verb deletes its disk. +a=$("$VMM" list -q | sort | tr '\n' ' ') +b=$(VMMDIR="$VMMDIR/" "$VMM" list -q | sort | tr '\n' ' ') +if [ "$a" = "$b" ]; then + ok "a trailing slash on VMMDIR names the same VMs" +else + notok "a trailing slash on VMMDIR names the same VMs" "[$a] vs [$b]" +fi + +out=$(VMMDIR=relative/path "$VMM" list 2>&1) && got=0 || got=$? +if [ "$got" != 0 ] && printf '%s' "$out" | grep -q 'absolute path'; then + ok "a relative VMMDIR is refused" +else + notok "a relative VMMDIR is refused" "exit $got: $out" +fi + +for v in SHUTDOWN_TIMEOUT MONITOR_TIMEOUT; do + for bad in abc 0 00 99999999999999999999; do + out=$(env "$v=$bad" "$VMM" list 2>&1) && got=0 || got=$? + if [ "$got" = 1 ] && printf '%s' "$out" | grep -q "$v must be"; then + ok "$v refuses $bad" + else + notok "$v refuses $bad" "exit $got: $out" + fi + done +done -- cgit v1.2.3