fix typo
[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 and TARGET_ARCH
17 CONFIG=qemu.conf
18 if [ ! -e ${CONFIG} ];then
19     echo "File for node_iso version not found"
20     exit 1
21 fi
22 . $CONFIG
23
24 # the launcher, depending on local/target archs
25 archs="$(uname -i)+$TARGET_ARCH"
26 case $archs in
27     i386+i386)          QEMU=qemu;;
28     i386+x86_64)        QEMU=qemu-system-x86_64;;
29     x86_64+i386)        QEMU=qemu;;
30     x86_64+x86_64)      QEMU=qemu-system-x86_64;;
31 esac
32
33 #Creating new HDA if needed only
34 #using qcow2 disk image format which is essential to support VM snapshots
35 if [ -f $HDA ] ; then
36     echo "Using existing $HDA"
37 else
38     echo -n "Creating hard disk image (${DISK_SIZE}) as $HDA .. "
39     img=$($QEMU_CREATE_IMAGE)
40     if [ -z "$img" ];then
41         echo "Failed"
42         exit 1
43     fi
44     echo "Done"
45 fi
46
47 rm -f qemu.pid
48
49 #Command for running the Qemu Emulator
50 ARGS="-boot d  -net nic,macaddr=${MACADDR} -net $TAP, -cdrom ${NODE_ISO} -hda ${HDA} -m ${RAM} -nographic -pidfile qemu.pid"
51 echo "Running $QEMU $ARGS < /dev/null"
52 exec $QEMU $ARGS < /dev/null