-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpp_run.sh
executable file
·108 lines (90 loc) · 3.58 KB
/
pp_run.sh
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
# Copyright (c) 2017 Takayuki Imada <takayuki.imada@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#! /bin/bash
# Parameters (can be modified)
GUEST="Mirage" # used for a JSON output file
OCAMLVER="4.03.0+flambda" # used for a JSON output file
CLIENTADDR="localhost" # client side Libvirt IP where the pingpong client program runs
SERVERADDR="localhost" # server side Libvirt IP where the pingpong server program runs
PP_CLIENTADDR="192.168.122.101/24" # pp_client IP address with its network mask
PP_SERVERADDR="192.168.122.100/24" # pp_server IP address with its network mask
USER="root" # a user name to execute programs
# Parameters (should not be modified)
APP="pp"
BUF="1"
PLATFORM=${1}
BASEDIR=${2}
CLIENTPATH="./${APP}/${APP}_client"
SERVERPATH="./${APP}/${APP}_server"
CLIENTXML="${PLATFORM}_client.xml"
SERVERXML="${PLATFORM}_server.xml"
CLIENTBIN="${APP}_client.${PLATFORM}"
SERVERBIN="${APP}_server.${PLATFORM}"
# Check the arguments provided
case ${PLATFORM} in
"xen" )
VIRSH_C="virsh -c xen+ssh://${CLIENTADDR}";
VIRSH_S="virsh -c xen+ssh://${SERVERADDR}";
;;
"virtio" )
VIRSH_C="virsh -c qemu+ssh://${CLIENTADDR}/system";
VIRSH_S="virsh -c qemu+ssh://${SERVERADDR}/system";
;;
* ) echo "Invalid hypervisor selected"; exit
esac
COMPILER="OCaml ${OCAMLVER}"
# switch an OCaml compiler version to be used
opam switch ${OCAMLVER}
eval `opam config env`
# Build and dispatch a server application
cd ./${SERVERPATH}
make clean
mirage configure --ipv4=${PP_SERVERADDR} -t ${PLATFORM}
make
cd ../
sed -e s@KERNELPATH@${BASEDIR}/${SERVERBIN}@ ./template/${SERVERXML} > ./${SERVERXML}
scp ./${SERVERPATH}/${SERVERBIN} ${USER}@${SERVERADDR}:${BASEDIR}/
SERVERLOG="${OCAMLVER}_${PLATFORM}_${APP}_server.log"
${VIRSH_S} create ./${SERVERXML}
# Dispatch a client side MirageOS VM repeatedly
JSONLOG="./${OCAMLVER}_${PLATFORM}_${APP}.json"
echo -n "{
\"guest\": \"${GUEST}\",
\"platform\": \"${PLATFORM}\",
\"compiler\": \"${COMPILER}\",
\"records\": [
" > ./${JSONLOG}
CLIENTLOG="${OCAMLVER}_${PLATFORM}_${APP}_client.log"
echo -n '' > ./${CLIENTLOG}
sed -e s@KERNELPATH@${BASEDIR}/${CLIENTBIN}@ ./template/${CLIENTXML} > ./${CLIENTXML}
cd ${CLIENTPATH}
make clean
mirage configure --ipv4=${PP_SERVERADDR} -t ${PLATFORM}
make
cd ../
scp ./${CLIENTPATH}/${CLIENTBIN} ${USER}@${CLIENTADDR}:${BASEDIR}/
sleep 3
echo -n "{ \"payload\": ${BUF}, \"latency\": [" >> ./${JSONLOG}
echo "***** Testing pingpong: Payload size ${BUF} *****"
${VIRSH_C} create ./${CLIENTXML} --console >> ${CLIENTLOG}
VALUES=`sed -e 's/^M/\n/g' ./${CLIENTLOG} | grep Latency | tail -n 1000 | cut -d' ' -f 8 | tr '\n' ','`
echo -n "${VALUES}" >> ./${JSONLOG}
echo -n "]}," >> ./${JSONLOG}
# Correct the generated JSON file
echo -n "]}" >> ./${JSONLOG}
sed -i -e 's/,\]/]/g' ${JSONLOG}
# Print statistics
cat ./${JSONLOG} | jq
# Destroy the server application
${VIRSH_S} destroy server