-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemulator.sh
More file actions
executable file
·57 lines (53 loc) · 1.38 KB
/
emulator.sh
File metadata and controls
executable file
·57 lines (53 loc) · 1.38 KB
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
#!/bin/bash
set -euo pipefail
: "${FORMAT:=efi}"
name=images/claylinux
case "$FORMAT" in
efi)
boot_opts=(-kernel "${name}.efi")
;;
raw)
boot_opts=(-drive "file=${name}.img,format=raw")
;;
qcow2)
boot_opts=(-drive "file=${name}.qcow2,format=qcow2")
;;
vmdk)
boot_opts=(-drive "file=${name}.vmdk,format=vmdk")
;;
vhdx)
boot_opts=(-drive "file=${name}.vhdx,format=vhdx")
;;
vdi)
boot_opts=(-drive "file=${name}.vdi,format=vdi")
;;
iso)
boot_opts=(-drive "file=${name}.iso,media=cdrom")
;;
*)
echo "invalid format '$FORMAT'" >&2
exit 1
;;
esac
# Use the proper accelerator
if [ -e /dev/kvm ]; then
boot_opts+=(-accel kvm -cpu host)
fi
# machine: q35 correspond to a modern PC
exec qemu-system-x86_64 \
-machine q35 \
-bios /usr/share/OVMF/OVMF.fd \
-m 2G \
-nodefaults \
-nographic \
-serial mon:stdio \
-netdev user,id=net \
-device virtio-net,netdev=net \
-device virtio-rng \
"${boot_opts[@]}" \
"$@"
# see https://gitlab.com/qemu-project/qemu/-/issues/513
# smm=on
# -global driver=cfi.pflash01,property=secure,value=on \
# -drive if=pflash,format=raw,unit=0,file=out/OVMF_CODE.fd,readonly=on \
# -drive if=pflash,format=raw,unit=1,file=out/OVMF_VARS.fd \