-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_w_qemu.sh
More file actions
executable file
·79 lines (73 loc) · 2.15 KB
/
Copy pathtest_w_qemu.sh
File metadata and controls
executable file
·79 lines (73 loc) · 2.15 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
echo $0 Got arguments: $*
bootfile="boot.ipxe"
USEEFI=""
VNC="-vnc 127.0.0.1:22"
VGA=""
efibios=""
memorygb=4
POSITIONAL=()
while (($#)); do
case $1 in
-bootfile)
shift
bootfile=$1
;;
useefi)
USEEFI=YES
cp /usr/share/edk2-ovmf/OVMF_VARS.fd kvm_lxgentootest_VARS.fd
efibios="-drive if=pflash,unit=0,format=raw,readonly=on,file=/usr/share/edk2-ovmf/OVMF_CODE.fd \
-drive if=pflash,unit=1,format=raw,file=kvm_lxgentootest_VARS.fd"
cp $bootfile autoexec.ipxe
[ -f ipxe.efi ] || (wget https://boot.ipxe.org/x86_64-efi/ipxe-legacy.efi && mv ipxe-legacy.efi 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"
# TODO add warning if online and serial since there will be no console
;;
direct)
# TODO if serial add console
(cat gentoo.igz; (echo image.squashfs | cpio -H newc -o)) > combined.igz
POSITIONAL+=("-kernel" "gentoo" "-initrd" "combined.igz" "-append" "dokeymap looptype=squashfs loop=/image.squashfs cdroot")
bootfile=""
;;
-m)
shift
echo "Set memory to $1 gb"
memorygb=$1
;;
*)
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) &
if [[ -z "$VNC" ]]; then
# if serial make sure autoexec.ipxe is set for serial console
[[ "$USEEFI" != "YES" ]] && cp $bootfile autoexec.ipxe && bootfile="autoexec.ipxe"
sed -i 's/ cdroot/ cdroot console=ttyS0,115200/' autoexec.ipxe
sed -i 's/vga=791//' autoexec.ipxe
fi
netscript="-nic user,model=virtio,tftp=.,bootfile=$bootfile"
set -x
jn=$(($(nproc)/2))
qemu-system-x86_64 -enable-kvm -M q35 -m $(($memorygb*1024)) -cpu host -smp $jn,cores=$jn,sockets=1 -name lxgentootest \
$netscript \
-device i6300esb -action watchdog=reset \
-device virtio-rng-pci \
-usb ${VGA} ${VNC} \
${efibios} \
$*