4 # it does the following:
5 # (*) close all file descriptors and redirect output to log.txt
6 # this is because it is designed for use through ssh from a remote test master controller
7 # (*) initialize a disk image if it does not exist yet
8 # (*) starts a qemu instance
10 # cd in this command's directory
11 COMMAND=$(basename $0)
19 DISK_IMAGE=hdd-${DISK_FORMAT}-${DISK_SIZE}.img
23 ####### we want this script to be invokable through ssh without the ssh client to remain hanging
28 # redirect stderr on stdout
31 ########## from the test environment
32 # expected vars are MACADDR, NODE_ISO, HOSTNAME, IP and TARGET_ARCH
34 [ -f "$CONFIG" ] || { echo "Config file for qemu $CONFIG not found in $(pwd)" ; exit 1 ; }
37 # the launcher, depending on target arch
38 # make sure to check qemu-kill-node for consistency
40 i386) QEMU=qemu ; ARGS="" ;;
41 x86_64) QEMU=qemu-system-x86_64 ; ARGS="-no-kqemu" ;;
42 *) echo "Cannot handle TARGET_ARCH=$TARGET_ARCH"; exit 1 ;;
45 echo "Running $COMMAND in $(pwd)"
46 echo "Starting at $(date)"
48 #Creating new DISK_IMAGE if needed only
49 if [ -f $DISK_IMAGE ] ; then
50 echo "Using existing $DISK_IMAGE"
52 echo -n "Creating hard disk image (${DISK_SIZE}) as $DISK_IMAGE .. "
53 img=$(qemu-img create -f ${DISK_FORMAT} $DISK_IMAGE ${DISK_SIZE})
61 echo 'Trying to load the kqemu module'
64 echo 'Checking for a loaded kqemu module'
66 echo 'Checking for /dev/kqemu'
69 echo 'Cleaning up pid file'
76 ARGS="$ARGS -m ${RAM}"
77 ARGS="$ARGS -hda ${DISK_IMAGE}"
78 ARGS="$ARGS -nographic"
79 ARGS="$ARGS -pidfile qemu.pid"
82 ARGS="$ARGS -cdrom ${NODE_ISO}"
84 ARGS="$ARGS -net nic,macaddr=${MACADDR}"
86 ARGS="$ARGS -net tap,script=${SCRIPT}"
87 echo "Running $QEMU $ARGS"