-
Notifications
You must be signed in to change notification settings - Fork 20
/
do-httpreply
executable file
·77 lines (68 loc) · 2.24 KB
/
do-httpreply
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
#!/bin/bash
# https://stackoverflow.com/a/246128/4804196
SOURCE=${BASH_SOURCE[0]}
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
SOURCE=$(readlink "$SOURCE")
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
source "$SCRIPT_DIR"/../include/base
app="$top"/apps/app-httpreply
source "$SCRIPT_DIR"/../include/common_functions
setup_app()
{
if ! test -d "$app"; then
git clone https://github.com/unikraft/app-httpreply "$app"
fi
}
run()
{
_setup_networking
if test ! -d "$app"; then
echo "$app folder doesn't exist. Did you run '$0 setup'?" 1>&2
exit 1
fi
pushd "$app" > /dev/null
export UK_WORKDIR=$(pwd)/../../
kraft run -b virbr0 "netdev.ipv4_addr=172.44.0.2 netdev.ipv4_gw_addr=172.44.0.1 netdev.ipv4_subnet_mask=255.255.255.0 --"
popd > /dev/null
}
run_qemu()
{
_setup_networking
if test ! -d "$app"; then
echo "$app folder doesn't exist. Did you run '$0 setup'?" 1>&2
exit 1
fi
pushd "$app" > /dev/null
sudo qemu-system-x86_64 \
-kernel build/httpreply_kvm-x86_64 \
-cpu host \
-enable-kvm \
-nographic \
-netdev bridge,id=en0,br=virbr0 \
-device virtio-net-pci,netdev=en0 \
-append "netdev.ipv4_addr=172.44.0.2 netdev.ipv4_gw_addr=172.44.0.1 netdev.ipv4_subnet_mask=255.255.255.0 --"
popd > /dev/null
}
run_debug()
{
_setup_networking
if test ! -d "$app"; then
echo "$app folder doesn't exist. Did you run '$0 setup'?" 1>&2
exit 1
fi
pushd "$app" > /dev/null
sudo qemu-system-x86_64 \
-kernel build/httpreply_kvm-x86_64.dbg \
-cpu host \
-enable-kvm \
-nographic \
-netdev bridge,id=en0,br=virbr0 \
-device virtio-net-pci,netdev=en0 \
-append "netdev.ipv4_addr=172.44.0.2 netdev.ipv4_gw_addr=172.44.0.1 netdev.ipv4_subnet_mask=255.255.255.0 --" \
-gdb tcp::1234 -S
popd > /dev/null
}
source "$SCRIPT_DIR"/../include/common_command