# ARCH picks the qemu binary, the machine type and the display device. # Nothing here needs /dev/kvm: another architecture is emulated. "$VMM" create ar1 64M >/dev/null 2>&1 FW=/usr/share/qemu/edk2-aarch64-code.fd [ -f "$FW" ] || FW=/usr/share/AAVMF/AAVMF_CODE.fd cfg ar1 < "$VMMDIR/ar1/config" outputs 'accel=kvm' "the host architecture gets kvm" dryrun ar1 outputs "-cpu 'host'" "the host architecture gets the host cpu" dryrun ar1 # A host with no /dev/kvm can still run its own architecture, slowly. cfg ar1 < "$VMMDIR/ar1/config" out=$(PATH=$NOQEMU "$VMM" start ar1 2>&1) && got=0 || got=$? if [ "$got" != 0 ] && printf '%s' "$out" | grep -q 'qemu-system-.* is not on PATH'; then ok "a qemu that is not installed is named at once" else notok "a qemu that is not installed is named at once" "exit $got: $out" fi # Emulated end to end: the firmware really runs and really talks to the # serial console, which is the whole point of passing -bios. if [ -f "$FW" ] && command -v qemu-system-aarch64 >/dev/null 2>&1; then cfg ar1 </dev/null 2>&1 || : else skip 3 "no qemu-system-aarch64 or no aarch64 firmware" fi # Failure after spawn must reap only that child and remove every runtime # object it may have created. if command -v "qemu-system-$(uname -m)" >/dev/null 2>&1; then "$VMM" create ar2 64M >/dev/null 2>&1 printf 'not a qcow2 image\n' > "$VMMDIR/ar2/disk.qcow2" cfg ar2 < "$FAKE" <<'EOF' #!/bin/sh sleep 5 EOF chmod +x "$FAKE" "$VMM" create ar3 64M >/dev/null 2>&1 out=$(PATH=$FAKEBIN:$PATH MONITOR_TIMEOUT=1 "$VMM" start ar3 2>&1) && got=0 || got=$? if [ "$got" = 1 ]; then ok "a start whose monitor never answers fails" else notok "a start whose monitor never answers fails" "exit $got: $out" fi left= for cmdline in /proc/[0-9]*/cmdline; do line= IFS= read -r line 2>/dev/null < "$cmdline" || : case $line in *"-pidfile$VMMDIR/ar3/pid") p=${cmdline#/proc/} left="$left ${p%/cmdline}" ;; esac done if [ -z "$left" ]; then ok "and kills the child it spawned" else notok "and kills the child it spawned" "still running:$left" # shellcheck disable=SC2086 # a list of pids this loop collected kill -9 $left 2>/dev/null || : fi