about summary refs log tree commit diff stats
path: root/tools/scripts/system-qemu.sh
blob: 489af5ee3623ff440c134a07c4c0f68e5f111de5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

# First we define the function
ConfirmOrExit ()
{
    while true
    do
        echo -n "Please confirm (y or n) :"
        read CONFIRM
        case $CONFIRM in
            y|Y|YES|yes|Yes) break ;;
            n|N|no|NO|No)
                echo "Aborting - you entered $CONFIRM"
                exit
                ;;
            *) echo "Please enter only y or n"
        esac
    done
    echo "You entered $CONFIRM. Continuing ..."
}

SCRIPT=$(readlink -f "$0")
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")

DIR=$(dirname "$SCRIPTPATH");
DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";

MEM=$1
TAP=$2
ISO_FILE="${DIR_LOCAL}/$3"
IMG="${DIR_LOCAL}/$4"

echo "MEM (512): $MEM"
echo "TAP (tap1): $TAP"
echo "ISO_FILE (crux-3.2.iso): $ISO_FILE"
echo "IMG (crux-img.qcow2): $IMG"
ConfirmOrExit

if [ "$ISO_FILE" = "$DIR_LOCAL/" ]
then
    qemu-system-x86_64 \
        -enable-kvm \
        -m $MEM \
        -boot c \
        -hda ${IMG} \
        -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
else
    qemu-system-x86_64 \
        -enable-kvm \
        -m $MEM \
        -boot d \
        -cdrom ${ISO_FILE} \
        -hda ${IMG} \
        -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
fi

exit 0;