2015-06-15 19:12:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2015 Canonical, Ltd.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-06-17 18:09:52 +00:00
|
|
|
ARCH=${ARCH-"`uname -m`"}
|
2015-06-15 19:12:26 +00:00
|
|
|
MEM=${MEM-"1024"}
|
|
|
|
INSTALLER=${INSTALLER-"installer.img"}
|
2015-09-22 18:37:51 +00:00
|
|
|
UEFI=${UEFI-"1"}
|
2015-06-15 19:12:26 +00:00
|
|
|
TARGET=${TARGET-"target.img"}
|
|
|
|
SPORT=2445
|
|
|
|
|
2015-06-17 18:09:52 +00:00
|
|
|
QEMU=`which qemu-system-$ARCH`;
|
|
|
|
if [ -z $QEMU ]; then
|
|
|
|
case $ARCH in
|
|
|
|
i386|x86_64) PKG=qemu-system-x86 ;;
|
|
|
|
arm*) PKG=qemu-system-arm ;;
|
|
|
|
ppc*) PKG=qemu-system-ppc ;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported arch: $ARCH";
|
|
|
|
exit 1;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
sudo apt-get install $PKG || {
|
|
|
|
echo "Failed to install qemu-system package $PKG";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2015-09-22 18:37:51 +00:00
|
|
|
if [ "${UEFI}" == "1" ]; then
|
|
|
|
UEFI=" -bios /usr/share/ovmf/OVMF.fd"
|
|
|
|
else
|
|
|
|
UEFI=""
|
|
|
|
fi
|
|
|
|
|
2015-07-06 15:55:49 +00:00
|
|
|
# always recreate the target image
|
|
|
|
qemu-img create -f raw ${TARGET} 10G
|
|
|
|
|
2015-06-15 19:12:26 +00:00
|
|
|
# TODO, curses should work, but my xmonad setup blocks using it
|
2015-09-22 18:37:51 +00:00
|
|
|
sudo qemu-system-$ARCH -smp 2 -m $MEM -enable-kvm $UEFI\
|
|
|
|
-drive cache=unsafe,if=ide,file=$INSTALLER,serial=QM_INSTALL_01 \
|
|
|
|
-drive cache=unsafe,if=ide,file=$TARGET,serial=QM_TARGET_01 \
|
2015-07-06 18:55:42 +00:00
|
|
|
-global isa-fdc.driveA= -net user \
|
2015-06-25 21:50:13 +00:00
|
|
|
-net nic,model=e1000 \
|
|
|
|
-net nic,model=virtio \
|
|
|
|
-net nic,model=i82559er \
|
2015-06-15 19:12:26 +00:00
|
|
|
-monitor telnet:127.0.0.1:2446,server,nowait -serial stdio
|
|
|
|
#sudo qemu-system-$ARCH -m $MEM -enable-kvm -hda $INSTALLER -hdb $TARGET \
|
|
|
|
# -monitor telnet:127.0.0.1:2446,server,nowait -curses
|
|
|
|
|
|
|
|
exit $?
|