-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-vm
executable file
·66 lines (55 loc) · 1.87 KB
/
run-vm
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
#!/bin/zsh
set -e
zmodload zsh/zutil
show-usage() {
echo "Usage: KERNEL [ARG [...]] [-- QEMU-ARG [...]]"
echo "The kernel image is mandatory."
echo
echo "ARG:"
echo " -h|--help This..."
echo " -C|--no-cov Suppress LCOV capture."
echo " -T|--tag Add tag to output dir name (repeats)."
echo " -d|--debug [PORT] Wait for GDB on tcp::PORT (default 1234)."
echo
echo "QEMU-ARGs can be used to fine-tune Qemu."
exit 1
}
zparseopts -D -F -E - {-help,h}=help {-tag,T}+:=tags {-no-cov,C}=ncov {-debug,d}::=debug {-test,t}+:=tests || show-usage
(( $#help > 0 )) && show-usage
[[ -f $1 ]] && kernel=$1 && shift || show-usage
[[ $1 == "--" ]] && shift
tags=${${(pj:+:)${tags/(--tag|-T)/}}// /_}
cpus=1
mem=2G
out="${0:A:h:h}/output/$(uname -n)-$(date -Iseconds)${tags:+-$tags}"
root=${0:A:h:h}/_build
efidisk=${root}/efi.img
vardisk=${root}/var.img
params=(
--name "pkvm-test-runner"
--machine virt,virtualization=true,gic-version=3
--smp $cpus -m $mem --cpu cortex-a72
--drive if=pflash,file=${efidisk},format=raw,readonly=on
--drive if=pflash,file=${vardisk},format=raw
--virtfs local,path=$out,mount_tag=output,security_model=none
--nographic
--no-reboot # Exit instead of rebooting
--kernel $kernel
--initrd ${root}/initramfs.img
)
(( $#debug )) && params+=( -S --gdb tcp::${${${debug[1]/--debug}/-d}:-1234} )
# linux/Documentation/admin-guide/kernel-parameters.txt:
append=(
panic=-1 # Reboot immediately.
nokaslr # Disable address space layout randomization.
quiet # Suppress kernel outputs.
kvm-arm.mode=protected # pKVM.
)
arguments=($params --append "$append" $@)
mkdir -p $out
echo $arguments > $out/arguments
make -C ${0:A:h:h} images
qemu-system-aarch64 $arguments | tee "$out/serial"
(( $#ncov == 0 )) && echo && ${0:A:h}/capture-coverage $out
echo
echo -e '> \e]8;;file://'$out'\e\\'$out'\e]8;;\e\\'