377ff5fff06d77fad1ec8a75ab91c0d05a6afec6
[tests.git] / system / template-qemu / start-qemu-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 - mostly MACADDR and NODE_ISO
7 CONFIG=qemu.conf
8 if [ ! -e ${CONFIG} ];then
9     echo "File for node_iso version not found"
10     exit 1
11 fi
12 . $CONFIG
13
14 #default Value
15 #always use the 64 bit version of qemu, as this will work on both 32 & 64 bit host kernels
16 QEMU=qemu
17 HDA=hda_5.img
18 RAM=1024
19
20 SCRIPT=qemu-ifup
21 TAP="tap,script=$SCRIPT"
22
23 #Creating new HDA if needed only
24 #using qcow2 disk image format which is essential to support VM snapshots
25 if [ -f $HDA ] ; then
26     echo "Using $HDA"
27 else
28     echo "Creating hard disk for Qemu install under $HDA"
29     img=$(qemu-img create -f qcow2 $HDA 5G)
30     if [ -z "$img" ];then
31         echo "Can't Create disk image..."
32         exit 1
33     fi
34 fi
35
36 echo "New $HDA is created..."
37
38 rm -f qemu.pid
39
40 #Command for running the Qemu Emulator
41 ARGS="-boot d  -net nic,macaddr=${MACADDR} -net $TAP, -cdrom ${NODE_ISO} -hda ${HDA} -m ${RAM} -nographic  -pidfile qemu.pid"
42 echo $$ > shell.pid
43 echo "Running $QEMU $ARGS < /dev/null"
44 exec $QEMU $ARGS < /dev/null