blob: 3e4548c93e4435719597d0db92cb3649cc1f768e (
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
|
#!/bin/sh
Q_ARCH='x86_64'
Q_NAME='qemu'
Q_SSH_PORT='2222'
USAGE="usage: `basename $0` [options] [--] [qemu options...]
Options:
-A ARCH VM architecture
-p PORT The port on localhost to map to the VM's sshd. [2222]
-d FILE Set disk
-n NAME Set name
-h This ;-)
A simple wrapper around qemu for running balenaOS images.
See the qemu(1) man page for more details.
"
Q_ARGS=""
while getopts ":hvd:A:n:" o; do
case "$o" in
A)
Q_ARCH="$OPTARG"
die "Found \"-$o $Q_ARCH\", not supported yet!" ;;
d)
Q_DISK="$OPTARG"
Q_ARGS="${Q_ARGS} -drive file="${Q_DISK}",media=disk,cache=none,format=raw" ;;
p)
Q_SSH_PORT="$OPTARG" ;;
n)
Q_NAME="$OPTARG" ;;
v)
set -x ;;
h|*)
echo "$USAGE"
exit ;;
esac
done
shift $(($OPTIND-1))
case "${Q_ARCH}" in
x86_64|amd64)
qemu-system-x86_64 \
-name "$Q_NAME" \
-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 \
-net nic,model=virtio -net user \
-nic user,hostfwd=tcp::${Q_SSH_PORT}-:22222 \
-machine type=pc,accel=kvm -smp 4 -cpu host \
${Q_ARGS} \
"$@"
;;
*) die "Unsupported arch" ;;
esac
exit $?
|