does not scratch disk image if already existing
[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=start-qemu.conf
8 if [ ! -e ${CONFIG} ];then
9     echo "File for MAC Address not found"
10     exit 1
11 fi
12 . $CONFIG
13
14 #default Value
15 QEMU=qemu-system-x86_64
16 HDA=hda_10.raw
17 RAM=520;
18
19 SCRIPT=./qemu-ifup
20 TAP="tap,script=$SCRIPT";
21
22
23 ##check for the creation of new HDA
24 #if [ -e "$HDA" ]; then
25 #    echo "Disk already existing removing  it..."
26 #    rm -rf $HDA
27 #fi
28 #
29
30 #Creating new HDA if needed only
31 if [ -f $HDA ] ; then
32     echo "Using $HDA"
33 else
34     echo "Creating hard disk for Qemu install under $HDA"
35     img=$(qemu-img create $HDA 10G)
36     if [ -z "$img" ];then
37         echo "Can't Create disk image..."
38         exit 1
39     fi
40 fi
41
42 echo "New $HDA is created..."
43
44 #Command for running the Qemu Emulator
45 ARGS="-boot d -cdrom ${NODE_ISO} -hda ${HDA} -m ${RAM}  -net nic,macaddr=${MACADDR} -net $TAP -nographic -pidfile qemu.pid"
46 echo $$ > shell.pid
47 echo "Running qemu $ARGS"
48 $QEMU $ARGS
49
50
51 exit