open up traffic to qemu nodes + miscell
[tests.git] / system / template-qemu / qemu-start-node
1 #!/bin/bash
2
3 # cd in this command's directory
4 cd $(dirname $0)
5
6 ########## globals
7 RAM=1024
8 DISK_SIZE=10G
9 HDA=hdd-cow2-${DISK_SIZE}.img
10 QEMU_CREATE_IMAGE="qemu-img create -f qcow2 $HDA ${DISK_SIZE}"
11
12 SCRIPT=qemu-ifup
13 TAP="tap,script=$SCRIPT"
14
15 ########## from the test environment
16 # expected vars are MACADDR, NODE_ISO, HOSTNAME, IP and TARGET_ARCH
17 CONFIG=qemu.conf
18 [ -f "$CONFIG" ] || { echo "Config file for qemu $CONFIG not found in $(pwd)" ; exit 1 ; }
19 . $CONFIG
20
21 # the launcher, depending on local/target archs
22 # make sure to check qemu-kill-node for consistency
23 archs="$(uname -i)+$TARGET_ARCH"
24 case $archs in
25     i386+i386)          QEMU=qemu;;
26     i386+x86_64)        QEMU=qemu-system-x86_64;;
27     x86_64+i386)        QEMU=qemu;;
28     x86_64+x86_64)      QEMU=qemu-system-x86_64;;
29 esac
30
31 #Creating new HDA if needed only
32 #using qcow2 disk image format which is essential to support VM snapshots
33 if [ -f $HDA ] ; then
34     echo "Using existing $HDA"
35 else
36     echo -n "Creating hard disk image (${DISK_SIZE}) as $HDA .. "
37     img=$($QEMU_CREATE_IMAGE)
38     if [ -z "$img" ];then
39         echo "Failed"
40         exit 1
41     fi
42     echo "Done"
43 fi
44
45 rm -f qemu.pid
46
47 #Command for running the Qemu Emulator
48 ARGS="-boot d  -net nic,macaddr=${MACADDR} -net $TAP, -cdrom ${NODE_ISO} -hda ${HDA} -m ${RAM} -nographic -pidfile qemu.pid"
49 echo "Running $QEMU $ARGS < /dev/null"
50 exec $QEMU $ARGS < /dev/null