#!/bin/bash
#
# Quick'n'dirty qemu-system-arm wrapper
#
# This is a temporary wrapper script to enable qemu-system-arm 2.1.2's
# 'versatilepb' to be managed by libvirt.
# To use it:
#
#  1. mv /usr/bin/qemu-system-arm /usr/bin/qemu-system-arm.bin
#  2. save this script as /usr/bin/qemu-system-arm with 
#     appropriate permissions
#
# Sun Nov 16 2014 Carl van Tonder <carl@supervacuo.com>
#
# (original script[0] by Chris Taylor, chris.tylers.info)
# [0] http://fedoraproject.org/wiki/Architectures/ARM/HowToQemu

LOGFILE=/tmp/qemu_args.log

ARGS="$(echo $@|                                     \
        sed                                            \
		 -e "s/-device ide-hd.*bootindex=1//g" \
		 -e "s/,if=none,id=drive-ide0-0-0,format=raw//g" \
)"
echo "Date: $(date)" >>$LOGFILE
echo "Original args: $*" >>$LOGFILE
echo "Edited args: $ARGS" >>$LOGFILE

echo $ARGS | xargs /usr/bin/qemu-system-arm.bin

RESULT=$?
echo "Result code: $RESULT" >>$LOGFILE
(echo "ID: ";id) >>/tmp/qemu.log

exit $?
