Skip to content

Instantly share code, notes, and snippets.

@kanaka
Created December 1, 2017 22:45
Show Gist options
  • Save kanaka/8a97844fea03d32b016e4fbff5eb171b to your computer and use it in GitHub Desktop.
Save kanaka/8a97844fea03d32b016e4fbff5eb171b to your computer and use it in GitHub Desktop.
mal run script for running low-level code within qemu/kvm
#!/bin/bash
(
sleep 0.1
while ! exec 3<> /dev/tcp/localhost/21118; do
sleep 0.1
done
while read -u 3 -r cmd arg1; do
case ${cmd} in
slurp:)
if [ -r "${arg1}" ]; then
echo "fdata: $(stat --printf="%s" ${arg1})" >&3
cat >&3 ${arg1}
else
echo "error: Could not read file ${arg1}" >&3
fi
;;
*)
echo >&2 "Unknown socket command: $cmd"
;;
esac
done
) &
kvm -nographic \
-monitor none \
-serial stdio \
-serial tcp:localhost:21118,server \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-cdrom $(dirname $0)/${STEP:-stepA_mal}.iso
exit $(( $? / 2 ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment