blob: d95e91425be52b0dfc2e34364d1c3991fc0b3750 (
plain)
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
|
#!/bin/bash
#############################################################################
#Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
set -e
# Commandline arguments
src=$2
dst=$3
dst_ip=$4
migrate_to_port=$5
max_down_time=$6
OUTPUT_FILE=/tmp/output-qemu.log
do_migrate()
{
echo "Execution of Live Migration"
echo "info status" | nc -U $src
# with no speed limit
echo "migrate_set_speed 0" | nc -U $src
# set the expected max downtime
echo "migrate_set_downtime ${max_down_time}" | nc -U $src
# start live migration
echo "migrate -d tcp:${dst_ip}:${migrate_to_port}" | nc -U $src
# wait until live migration completed
status=""
while [ "${status}" == "" ]
do
status=`echo "info migrate" | nc -U $src |grep completed | cut -d: -f2`
echo ${status}
sleep 1;
done
echo "End of Live Migration"
} > /dev/null
output_qemu()
{
echo "Checking status of Migration"
# print detail information
echo "info migrate" | nc -U $src
echo "quit" | nc -U $src
echo "quit" | nc -U $dst
sleep 5
echo "Migration executed successfully"
} > $OUTPUT_FILE
output_json()
{
totaltime=$(grep "total time" $OUTPUT_FILE | cut -d' ' -f3)
downtime=$(grep "downtime" $OUTPUT_FILE | cut -d' ' -f2)
setuptime=$(grep "setup" $OUTPUT_FILE | cut -d' ' -f2)
echo -e "{ \
\"totaltime\":\"$totaltime\", \
\"downtime\":\"$downtime\", \
\"setuptime\":\"$setuptime\" \
}"
}
# main entry
main()
{
# Perform LiveMigration
do_migrate
# LiveMigration Status
output_qemu
# LiveMigration JSON output
output_json
}
main
|