forked from unikraft-upb/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
do-unikraft-redis
executable file
·124 lines (103 loc) · 2.79 KB
/
do-unikraft-redis
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
#!/bin/bash
top=unikraft-redis
libs=unikraft-redis/libs
apps=unikraft-redis/libs
uk=unikraft-redis/unikraft
app=unikraft-redis/apps/app-redis
setup()
{
mkdir -p "$top"
mkdir -p "$libs"
mkdir -p "$apps"
git clone https://github.com/unikraft/unikraft "$uk"
git clone https://github.com/unikraft/app-redis "$app"
git clone https://github.com/unikraft/lib-redis "$libs"/redis
git clone https://github.com/unikraft/lib-newlib "$libs"/newlib
git clone https://github.com/unikraft/lib-pthread-embedded "$libs"/pthread-embedded
git clone https://github.com/unikraft/lib-lwip "$libs"/lwip
pushd "$app" > /dev/null
git remote add upb https://github.com/unikraft-upb/app-redis
git fetch upb
git checkout -b use-9pfs upb/use-9pfs
popd > /dev/null
}
build()
{
pushd "$app" > /dev/null
export UK_WORKDIR=$(pwd)/../../
kraft configure -F -m x86_64 -p kvm
kraft build -j $(nproc)
popd > /dev/null
}
clean()
{
pushd "$app" > /dev/null
export UK_WORKDIR=$(pwd)/../../
kraft clean -d
popd > /dev/null
}
remove()
{
rm -fr "$top"
}
_setup_networking()
{
sudo ip link set dev virbr0 down
sudo ip link del dev virbr0
sudo ip link add virbr0 type bridge
sudo ip address add 172.44.0.1/24 dev virbr0
sudo ip link set dev virbr0 up
}
run()
{
_setup_networking
pushd "$app" > /dev/null
export UK_WORKDIR=$(pwd)/../../
kraft run -M 512 -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 -- /redis.conf"
popd > /dev/null
}
run_qemu()
{
_setup_networking
pushd "$app" > /dev/null
sudo qemu-system-x86_64 -fsdev local,id=myid,path=$(pwd)/fs0,security_model=none \
-device virtio-9p-pci,fsdev=myid,mount_tag=fs0,disable-modern=on,disable-legacy=off \
-netdev bridge,id=en0,br=virbr0 \
-device virtio-net-pci,netdev=en0 \
-kernel "build/redis_kvm-x86_64" \
-append "netdev.ipv4_addr=172.44.0.2 netdev.ipv4_gw_addr=172.44.0.1 netdev.ipv4_subnet_mask=255.255.255.0 -- /redis.conf" \
-cpu host \
-enable-kvm \
-m 512M \
-nographic
popd > /dev/null
}
if test $# -ne 1; then
echo "Usage: $0 <command>" 1>&2
echo " command: setup build clean run run_qemu remove" 1>&2
exit 1
fi
command="$1"
case "$command" in
"setup")
setup
;;
"build")
build
;;
"clean")
clean
;;
"run")
run
;;
"run_qemu")
run_qemu
;;
"remove")
remove
;;
*)
echo "Unknown command"
exit 1
esac