fix
[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 HDA=hard_drive.img
8 RAM=1024
9 qemu-img create -f qcow2 $HDA 10G
10
11 SCRIPT=qemu-ifup
12 TAP="tap,script=$SCRIPT"
13
14 ########## from the test environment
15 # expected vars are MACADDR, NODE_ISO, HOSTNAME and TARGET_ARCH
16 CONFIG=qemu.conf
17 if [ ! -e ${CONFIG} ];then
18     echo "File for node_iso version not found"
19     exit 1
20 fi
21 . $CONFIG
22
23 # the launcher, depending on local/target archs
24 archs="$(uname -i)+$TARGET_ARCH"
25 case $archs in
26     i386+i386)          QEMU=qemu;;
27     i386+x86_64)        QEMU=qemu-system-x86_64;;
28     x86_64+i386)        QEMU=qemu;;
29     x86_64+x86_64)      QEMU=qemu-system-x86_64;;
30 esac
31
32 #Creating new HDA if needed only
33 #using qcow2 disk image format which is essential to support VM snapshots
34 if [ -f $HDA ] ; then
35     echo "Using $HDA"
36 else
37     echo "Creating hard disk (10G) for Qemu install under $HDA"
38     img=$($QEMU_CREATE_IMAGE)
39     if [ -z "$img" ];then
40         echo "Can't Create disk image..."
41         exit 1
42     fi
43     echo "New image $HDA created"
44 fi
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