#!/usr/bin/env bash # 2018 Luke Shumaker { set -euE image="$1" qemu=( qemu-system-x86_64 -machine accel=kvm -m 512 ) mountpoint=$(mktemp -dt -- "${0##*/}.XXXXXXXXXX") trap "rmdir -- ${mountpoint@Q}" EXIT sudo unshare --mount sh -c "mount --make-rslave / && mount ${image@Q} ${mountpoint@Q} && install -Dm755 /dev/stdin /etc/osi-run" "${qemu[@]}" -drive media=disk,format=raw,if=virtio,file="$1" sudo unshare --mount sh -c "mount --make-rslave / && mount ${image@Q} ${mountpoint@Q} && cat /var/log/osi-run.out; exit \$(cat /var/log/osi-run.status)" }