-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqemu.sh
executable file
·44 lines (39 loc) · 1.07 KB
/
qemu.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
41
42
43
44
#!/bin/sh
# live-tools/qemu.sh: very simple qemu wrapper
# initialize used variables
image="discard=unmap,detect-zeroes=unmap,if=virtio"
unset args
# process argument flags
while getopts 'SRAs:' opt; do
case $opt in
# select qemu interface
S) args="${args} -nographic"
;;
# select image format
R) image="format=raw,${image}"
;;
# pass two cores from host CPU
A) args="${args} -cpu host -smp 2"
;;
# add shared folder
s) args="${args} -fsdev local,security_model=none,id=qshare,path=${OPTARG}"
args="${args} -device virtio-9p-pci,fsdev=qshare,mount_tag=share"
;;
# bad command argument
\?)
printf '%s: %s\n' 'error' 'bad argument' 1>&2;
exit 1
;;
esac
done
# consume flags
shift $((OPTIND-1))
# disk image check
[ -n "${1}" -a -r "${1}" ] || {
printf "%s: %s\n" "${0}" 'need disk image' 1>&2
exit 1
}
image="${image},file=${1}"
shift
# start VM instance
exec qemu-system-x86_64 -enable-kvm -boot order=c -m 1G -drive "${image}" ${args} "$@"