another round of rework
[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 #Getting the env. as passed by the test framework
7 # expected vars are MACADDR, NODE_ISO, HOSTNAME and TARGET_ARCH
8 CONFIG=qemu.conf
9 if [ ! -e ${CONFIG} ];then
10     echo "File for node_iso version not found"
11     exit 1
12 fi
13 . $CONFIG
14
15 # the launcher, depending on local/target archs
16 archs="$(uname-i)+$(TARGET_ARCH)"
17 case $archs in
18     i386+i386)          QEMU= qemu;;
19     i386+x86_64)        QEMU= qemu-system-x86_64;;
20     x86_64+i386)        QEMU= qemu;;
21     x86_64+x86_64)      QEMU= qemu-system-x86_64;;
22 esac
23
24 QEMU=qemu
25 HDA=hard_drive.img
26 RAM=1024
27
28 SCRIPT=qemu-ifup
29 TAP="tap,script=$SCRIPT"
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 $HDA"
35 else
36     echo "Creating hard disk (10G) for Qemu install under $HDA"
37     img=$(qemu-img create -f qcow2 $HDA 10G)
38     if [ -z "$img" ];then
39         echo "Can't Create disk image..."
40         exit 1
41     fi
42 fi
43
44 echo "New $HDA is created..."
45
46 rm -f qemu.pid
47
48 #Command for running the Qemu Emulator
49 ARGS="-boot d  -net nic,macaddr=${MACADDR} -net $TAP, -cdrom ${NODE_ISO} -hda ${HDA} -m ${RAM} -nographic  -pidfile qemu.pid"
50 echo "Running $QEMU $ARGS < /dev/null"
51 exec $QEMU $ARGS < /dev/null