#!/bin/bash # cd in this command's directory cd $(dirname $0) ########## globals RAM=1024 DISK_SIZE=10G HDA=hdd-cow2-${DISK_SIZE}.img QEMU_CREATE_IMAGE="qemu-img create -f qcow2 $HDA ${DISK_SIZE}" SCRIPT=qemu-ifup TAP="tap,script=$SCRIPT" ########## from the test environment # expected vars are MACADDR, NODE_ISO, HOSTNAME, IP and TARGET_ARCH CONFIG=qemu.conf [ -f "$CONFIG" ] || { echo "Config file for qemu $CONFIG not found in $(pwd)" ; exit 1 ; } . $CONFIG # the launcher, depending on local/target archs # make sure to check qemu-kill-node for consistency archs="$(uname -i)+$TARGET_ARCH" case $archs in i386+i386) QEMU=qemu;; i386+x86_64) QEMU=qemu-system-x86_64;; x86_64+i386) QEMU=qemu;; x86_64+x86_64) QEMU=qemu-system-x86_64;; esac #Creating new HDA if needed only #using qcow2 disk image format which is essential to support VM snapshots if [ -f $HDA ] ; then echo "Using existing $HDA" else echo -n "Creating hard disk image (${DISK_SIZE}) as $HDA .. " img=$($QEMU_CREATE_IMAGE) if [ -z "$img" ];then echo "Failed" exit 1 fi echo "Done" fi rm -f qemu.pid #Command for running the Qemu Emulator ARGS="-boot d -net nic,macaddr=${MACADDR} -net $TAP, -cdrom ${NODE_ISO} -hda ${HDA} -m ${RAM} -nographic -pidfile qemu.pid" echo "Running $QEMU $ARGS < /dev/null" exec $QEMU $ARGS < /dev/null