master
py 115 lines 4.28 KB
Raw
1 #
2 # Migration test scenario parameter description
3 #
4 # Copyright (c) 2016 Red Hat, Inc.
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 #
19
20
21 class Scenario(object):
22
23 def __init__(self, name,
24 downtime=500,
25 bandwidth=125000, # 1000 gig-e, effectively unlimited
26 max_iters=30,
27 max_time=300,
28 pause=False, pause_iters=5,
29 post_copy=False, post_copy_iters=5,
30 auto_converge=False, auto_converge_step=10,
31 compression_mt=False, compression_mt_threads=1,
32 compression_xbzrle=False, compression_xbzrle_cache=10,
33 multifd=False, multifd_channels=2, multifd_compression="",
34 dirty_limit=False, x_vcpu_dirty_limit_period=500,
35 vcpu_dirty_limit=1):
36
37 self._name = name
38
39 # General migration tunables
40 self._downtime = downtime # milliseconds
41 self._bandwidth = bandwidth # MiB per second
42 self._max_iters = max_iters
43 self._max_time = max_time # seconds
44
45
46 # Strategies for ensuring completion
47 self._pause = pause
48 self._pause_iters = pause_iters
49
50 self._post_copy = post_copy
51 self._post_copy_iters = post_copy_iters
52
53 self._auto_converge = auto_converge
54 self._auto_converge_step = auto_converge_step # percentage CPU time
55
56 self._compression_mt = compression_mt
57 self._compression_mt_threads = compression_mt_threads
58
59 self._compression_xbzrle = compression_xbzrle
60 self._compression_xbzrle_cache = compression_xbzrle_cache # percentage of guest RAM
61
62 self._multifd = multifd
63 self._multifd_channels = multifd_channels
64 self._multifd_compression = multifd_compression
65
66 self._dirty_limit = dirty_limit
67 self._x_vcpu_dirty_limit_period = x_vcpu_dirty_limit_period
68 self._vcpu_dirty_limit = vcpu_dirty_limit
69
70 def serialize(self):
71 return {
72 "name": self._name,
73 "downtime": self._downtime,
74 "bandwidth": self._bandwidth,
75 "max_iters": self._max_iters,
76 "max_time": self._max_time,
77 "pause": self._pause,
78 "pause_iters": self._pause_iters,
79 "post_copy": self._post_copy,
80 "post_copy_iters": self._post_copy_iters,
81 "auto_converge": self._auto_converge,
82 "auto_converge_step": self._auto_converge_step,
83 "compression_mt": self._compression_mt,
84 "compression_mt_threads": self._compression_mt_threads,
85 "compression_xbzrle": self._compression_xbzrle,
86 "compression_xbzrle_cache": self._compression_xbzrle_cache,
87 "multifd": self._multifd,
88 "multifd_channels": self._multifd_channels,
89 "multifd_compression": self._multifd_compression,
90 "dirty_limit": self._dirty_limit,
91 "x_vcpu_dirty_limit_period": self._x_vcpu_dirty_limit_period,
92 "vcpu_dirty_limit": self._vcpu_dirty_limit,
93 }
94
95 @classmethod
96 def deserialize(cls, data):
97 return cls(
98 data["name"],
99 data["downtime"],
100 data["bandwidth"],
101 data["max_iters"],
102 data["max_time"],
103 data["pause"],
104 data["pause_iters"],
105 data["post_copy"],
106 data["post_copy_iters"],
107 data["auto_converge"],
108 data["auto_converge_step"],
109 data["compression_mt"],
110 data["compression_mt_threads"],
111 data["compression_xbzrle"],
112 data["compression_xbzrle_cache"],
113 data["multifd"],
114 data["multifd_channels"],
115 data["multifd_compression"])