Merge "bugfix: enable vlan and physical netwok able to set"
[yardstick.git] / yardstick / benchmark / scenarios / compute / qemu_migrate_benchmark.bash
1 #!/bin/bash
2
3 #############################################################################
4 #Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 set -e
13
14 # Commandline arguments
15
16 src=$2
17 dst_ip=$4
18 migrate_to_port=$5
19 max_down_time=$6
20
21 OUTPUT_FILE=/tmp/output-qemu.log
22
23 do_migrate()
24 {
25 #       local src=`echo $OPTIONS | cut -d ':' -f 2 | cut -d ',' -f 1`
26         echo "info status" | nc -U $src
27         # with no speed limit
28         echo "migrate_set_speed 0" |nc -U $src
29         # set the expected max downtime
30         echo "migrate_set_downtime ${max_down_time}" |nc -U $src
31         # start live migration
32         echo "migrate -d tcp:${dst_ip}:$migrate_to_port" |nc -U $src
33         # wait until live migration completed
34         status=""
35         while [  "${status}" == ""  ]
36         do
37                 status=`echo "info migrate" | nc -U $src |grep completed | cut -d: -f2`
38                 echo ${status}
39                 sleep 1;
40         done
41 } >/dev/null
42
43 output_qemu()
44 {
45         # print detail information
46         echo "info migrate" | nc -U $src
47         echo "quit" | nc -U $src
48         sleep 5
49
50 } > $OUTPUT_FILE
51
52 output_json()
53 {
54 totaltime=$(grep "total time" $OUTPUT_FILE | cut -d' ' -f3)
55 downtime=$(grep "downtime" $OUTPUT_FILE | cut -d' ' -f2)
56 setuptime=$(grep "setup" $OUTPUT_FILE | cut -d' ' -f2)
57 echo -e "{ \
58         \"totaltime\":\"$totaltime\", \
59         \"downtime\":\"$downtime\", \
60         \"setuptime\":\"$setuptime\" \
61          }"
62 }
63 # main entry
64 main()
65 {
66     do_migrate
67 }
68 main