-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
173 lines (144 loc) · 6.12 KB
/
justfile
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
proot := justfile_directory()
qemu_ssh_port := "2222"
user := `whoami`
default:
@just --choose
help:
just --list
ssh COMMAND="":
ssh \
-i {{proot}}/nix/ssh_key \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o IdentityAgent=/dev/null \
-F /dev/null \
-p {{qemu_ssh_port}} \
root@localhost -- "{{COMMAND}}"
vm-linux EXTRA_CMDLINE="" :
sudo qemu-system-x86_64 \
-cpu host \
-smp 4 \
-enable-kvm \
-m 16G \
-machine q35,accel=kvm,kernel-irqchip=split \
-device intel-iommu,intremap=on,device-iotlb=on,caching-mode=on \
-device virtio-serial \
-fsdev local,id=home,path={{proot}},security_model=none \
-device virtio-9p-pci,fsdev=home,mount_tag=home,disable-modern=on,disable-legacy=off \
-fsdev local,id=nixstore,path=/nix/store,security_model=none \
-device virtio-9p-pci,fsdev=nixstore,mount_tag=nixstore,disable-modern=on,disable-legacy=off \
-drive file={{proot}}/VMs/guest-image.qcow2 \
-net nic,netdev=user.0,model=virtio \
-netdev user,id=user.0,hostfwd=tcp:127.0.0.1:{{qemu_ssh_port}}-:22 \
-netdev bridge,id=en0,br=clicknet \
-device virtio-net-pci,netdev=en0 \
-nographic
#-device vfio-pci,host={{PASSTHROUGH}} \
#PASSTHROUGH=`yq -r '.devices[] | select(.name=="ethDut") | ."pci"' hosts/$(hostname).yaml`
vm-image-init:
#!/usr/bin/env bash
set -x
set -e
echo "Initializing disk for the VM"
mkdir -p {{proot}}/VMs
# build images fast
overwrite() {
install -D -m644 {{proot}}/VMs/ro/nixos.qcow2 {{proot}}/VMs/$1.qcow2
qemu-img resize {{proot}}/VMs/$1.qcow2 +8g
}
nix build .#guest-image --out-link {{proot}}/VMs/ro
overwrite guest-image
# use autotest tmux sessions: `just autotest-tmux ls`
autotest-tmux *ARGS:
#!/usr/bin/env python3
from configparser import ConfigParser, ExtendedInterpolation
import importlib.util
spec = importlib.util.spec_from_file_location("default_parser", "benchmark/pysrc/conf.py")
default_parser = importlib.util.module_from_spec(spec)
spec.loader.exec_module(default_parser)
conf = default_parser.default_config_parser()
conf.read("{{proot}}/benchmark/conf/uk_localhost.cfg")
import os
os.system(f"tmux -L {conf['common']['tmux_socket']} {{ARGS}}")
# connect to the autotest guest
autotest-ssh *ARGS:
#!/usr/bin/env python3
from configparser import ConfigParser, ExtendedInterpolation
import importlib.util
spec = importlib.util.spec_from_file_location("default_parser", "benchmark/pysrc/conf.py")
default_parser = importlib.util.module_from_spec(spec)
spec.loader.exec_module(default_parser)
conf = default_parser.default_config_parser()
conf.read("{{proot}}/benchmark/conf/uk_localhost.cfg")
import os
sudo = ""
if conf["host"]["ssh_as_root"]:
sudo = "sudo "
cmd = f"{sudo}ssh -F {conf['host']['ssh_config']} {conf['guest']['fqdn']} {{ARGS}}"
print(f"$ {cmd}")
os.system(cmd)
benchmark:
python3 benchmark/pysrc/measure_throughput.py -c benchmark/conf/uk_localhost.cfg -b -vvv
build-dependencies:
mkdir -p {{proot}}/nix/builds
nix build .#linux-pktgen -o {{proot}}/nix/builds/linux-pktgen
nix build --inputs-from . nixpkgs#qemu -o {{proot}}/nix/builds/qemu
nix build .#vpp2 -o {{proot}}/nix/builds/vpp
nix build .#click -o {{proot}}/nix/builds/click
build-click-og:
nix develop --unpack .#click
mv source libs/click-og
cd libs/click-og && nix develop .#click --command bash -c 'eval "$postPatch"'
cd libs/click-og && nix develop .#click --command bash -c './configure'
cd libs/click-og && nix develop .#click --command bash -c 'make -j$(nproc)'
downloadLibs:
@nix develop .#unikraft --command bash -c 'sourceRoot=$(pwd); eval "$postUnpack"'
kill:
sudo pkill -f "clicknet"
sudo pkill -f "controlnet"
throughput-cpio:
rm -r /tmp/ukcpio-$(USER) || true
mkdir -p /tmp/ukcpio-$(USER)
cp ./throughput.click /tmp/ukcpio-$(USER)/config.click
./libs/unikraft/support/scripts/mkcpio ./throughput.cpio /tmp/ukcpio-$(USER)
vm: throughput-cpio
sudo taskset -c 3,4 qemu-system-x86_64 \
-accel kvm -cpu max \
-m 1024M -object memory-backend-file,id=mem,size=1024M,mem-path=/dev/hugepages,share=on \
-mem-prealloc -numa node,memdev=mem \
-netdev bridge,id=en0,br=clicknet \
-device virtio-net-pci,netdev=en0 \
-append " vfs.fstab=[\"initrd0:/:extract::ramfs=1:\"] --" \
-kernel ./.unikraft/build/click_qemu-x86_64 \
-initrd ./throughput.cpio \
-nographic
vm-vhost: throughput-cpio
sudo taskset -c 3,4 qemu-system-x86_64 \
-accel kvm -cpu max \
-m 1024M -object memory-backend-file,id=mem,size=1024M,mem-path=/dev/hugepages,share=on \
-mem-prealloc -numa node,memdev=mem \
-chardev socket,id=char1,path=/tmp/vhost-user-okelmann-0,server \
-netdev type=vhost-user,id=hostnet1,chardev=char1 \
-device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:00:00:14 \
-append " vfs.fstab=[\"initrd0:/:extract::ramfs=1:\"] --" \
-kernel ./.unikraft/build/click_qemu-x86_64 \
-initrd ./throughput.cpio \
-nographic
vhost-user:
sudo ./result-examples/bin/dpdk-vhost -l 5-8 -n 4 --socket-mem 1024 -- --socket-file /tmp/vhost-user0 --client -p 1 --stats 1
vpp-notes:
# sudo vpp -c ./vpp.conf
# sudo vppctl -s /tmp/vpp-cli
# show log
# show interface
# create vhost-user socket /tmp/vhost-user0
# set int state VirtualEthernet0/0/0 up
# set interface l2 xconnect GigabitEthernet0/8/0.300 GigabitEthernet0/9/0.300
perf-kvm-top:
sudo perf kvm --guestkallsyms=./.unikraft/build/click_qemu-x86_64.sym --guestvmlinux=.unikraft/build/click_qemu-x86_64.dbg top -p $(pgrep qemu)
perf-kvm-record:
sudo perf kvm --guestkallsyms=./.unikraft/build/click_qemu-x86_64.sym --guestvmlinux=.unikraft/build/click_qemu-x86_64.dbg record -g -p $(pgrep qemu)
sudo perf kvm --guestkallsyms=./.unikraft/build/click_qemu-x86_64.sym --guestvmlinux=.unikraft/build/click_qemu-x86_64.dbg report
perf-qemu-record:
sudo perf record -g -p $(pgrep qemu)
sudo perf script > perf.trace