-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudboot.sh
executable file
·41 lines (34 loc) · 958 Bytes
/
cloudboot.sh
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
#!/bin/sh
# Halt on any errors
set -e
# Memory to use for this boot
INST_MEM=2048
# Attempt to find a qemu version we can use
if [ -e "/dev/kvm" ]; then
# We have KVM support, try to find a matching qemu
if [ `which qemu-kvm 2>&-` ]; then
QEMU_BIN=`which qemu-kvm`
elif [ -x "/usr/libexec/qemu-kvm" ]; then
QEMU_BIN=/usr/libexec/qemu-kvm
else
QEMU_BIN=`which qemu-system-x86_64`
fi
else
# No KVM support default to full emulation
QEMU_BIN=`which qemu-system-x86_64`
fi
# Check the arguments
if [ "$#" -ne "2" ]; then
echo "Usage: cloudboot.sh ostype config " >&2
# TODO: Known types
exit 1
fi
OS_NAME="${1}"
CONF_NAME="${2}"
IMG_NAME=${CONF_NAME}-${OS_NAME}.img
echo "Reminder: Press 'Ctrl-a x' to kill the VM."
echo " (See man qemu for more shortcuts)."
${QEMU_BIN} -nographic \
-m ${INST_MEM} \
-drive "file=output/${IMG_NAME},if=virtio" \
-net nic,model=virtio -net user