-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_w_qemu.sh
executable file
·59 lines (53 loc) · 1.42 KB
/
test_w_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
echo $0 Got arguments: $*
bootfile="combined.ipxe"
USEEFI=""
VNC="-vnc 127.0.0.1:22"
VGA=""
efibios=""
direct=("-boot" "menu=on")
POSITIONAL=()
while (($#)); do
case $1 in
useefi)
USEEFI=YES
# >=sys-firmware/edk2-ovmf-202008
efibios="-bios /usr/share/edk2-ovmf/OVMF_CODE.fd"
# TODO fix proper chain
[ -f ipxe.efi ] || wget http://boot.ipxe.org/ipxe.efi
bootfile="ipxe.efi"
;;
serial)
echo "using -nographic, Ctrl+A, X exits"
VNC=""
VGA="-nographic"
;;
useonline)
# iPXE which is default in qemu, supports http boot
bootfile="http://gentoo.ipxe.se/$bootfile"
;;
direct)
direct=("-kernel" "gentoo" "-initrd" "combined.igz" "-append" "root=/dev/ram0 init=/linuxrc dokeymap looptype=squashfs loop=/image.squashfs cdroot")
bootfile=""
;;
*)
POSITIONAL+=("$1") # save it in an array for later
;;
esac
shift
done
set -- "${POSITIONAL[@]}" # restore positional parameters
#VGA="-nographic -device sga"
#VGA="-nographic"
#VGA="-curses"
[[ "$USEEFI" != "YES" ]] && [[ "$VGA" == "" ]] && VGA="-vga vmware"
[[ "$VNC" != "" ]] && (sleep 3; vncviewer :22) &
netscript="-nic user,model=virtio,tftp=.,bootfile=$bootfile"
set -x
jn=$(nproc)
qemu-system-x86_64 -enable-kvm -M q35 -m 2048 -cpu host -smp $jn,cores=$jn,sockets=1 -name lxgentoopxetest \
$netscript \
-watchdog i6300esb -watchdog-action reset \
"${direct[@]}" -usb ${VGA} ${VNC} \
${efibios} \
$POSITIONAL