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/clone | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/clone (limited to 'tests/clone') diff --git a/tests/clone b/tests/clone new file mode 100644 index 0000000..b1ffb92 --- /dev/null +++ b/tests/clone @@ -0,0 +1,46 @@ +# clone and delete. + +"$VMM" create cl1 64M >/dev/null 2>&1 +cfg cl1 </dev/null | sed -n 's/.*mac=\([0-9a-f:]*\).*/\1/p') +m2=$("$VMM" dryrun cl2 2>/dev/null | sed -n 's/.*mac=\([0-9a-f:]*\).*/\1/p') +holds "the clone's MAC differs from its source's" \ + test -n "$m1" -a "$m1" != "$m2" + +exits 1 "clone refuses an existing destination" clone cl1 cl2 + +# Copy failures leave an incomplete destination without committing config. +mv "$VMMDIR/cl1/disk.qcow2" "$WORK/cl1.qcow2" +exits 1 "clone reports a disk copy failure" clone cl1 clf +holds "a failed clone leaves an incomplete directory" test -d "$VMMDIR/clf" +holds "a failed clone does not commit a config" test ! -e "$VMMDIR/clf/config" +mv "$WORK/cl1.qcow2" "$VMMDIR/cl1/disk.qcow2" + +# A partial destination is preserved for manual inspection. +mkdir -p "$VMMDIR/clx" +printf 'partial\n' > "$VMMDIR/clx/junk" +exits 1 "clone refuses an incomplete destination" clone cl1 clx +holds "the refused clone leaves the partial contents alone" \ + test -f "$VMMDIR/clx/junk" +unlink "$VMMDIR/clx/junk" +rmdir "$VMMDIR/clx" + +exits 0 "delete -f removes a stopped VM" delete -f cl2 +holds "delete really removes the directory" test ! -e "$VMMDIR/cl2" +holds "deleting a clone leaves the source disk alone" \ + test -f "$VMMDIR/cl1/disk.qcow2" +exits 1 "delete without -f and without a tty refuses" delete cl1 -- cgit v1.2.3