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/viewer | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/viewer (limited to 'tests/viewer') diff --git a/tests/viewer b/tests/viewer new file mode 100644 index 0000000..f0357f0 --- /dev/null +++ b/tests/viewer @@ -0,0 +1,44 @@ +# The URI is the whole of what viewer decides, and VIEWER=echo reports +# it without a client anywhere. The guests here are emulated. + +"$VMM" create vw1 64M >/dev/null 2>&1 + +exits 2 "viewer of an unknown VM exits 2" viewer nosuchvm +exits 3 "viewer of a stopped VM exits 3" viewer vw1 + +cfg vw1 </dev/null 2>&1; then + refuses 'has no display' "GRAPHICS=no leaves nothing to view" viewer vw1 + "$VMM" kill vw1 >/dev/null 2>&1 || : +else + skip 1 "vw1 did not start" +fi + +# The URI names the socket that is really there, not what the config +# says, so a display that failed to appear is an error rather than a +# client left dialling nothing. +for g in vnc spice; do + cfg vw1 </dev/null 2>&1; then + skip 2 "this qemu cannot do GRAPHICS=$g" + continue + fi + out=$(env VIEWER=echo "$VMM" viewer vw1 2>&1) && got=0 || got=$? + if [ "$got" = 0 ] && [ "$out" = "$g+unix://$VMMDIR/vw1/$g.sock" ]; then + ok "$g is handed to the client as $g+unix" + else + notok "$g is handed to the client as $g+unix" \ + "exit $got, wanted $g+unix://$VMMDIR/vw1/$g.sock" "got: $out" + fi + "$VMM" kill vw1 >/dev/null 2>&1 || : + exits 3 "and the killed $g guest has nothing to view" viewer vw1 +done -- cgit v1.2.3