summaryrefslogtreecommitdiff
path: root/tests/migration/guestperf/scenario.py
blob: 705c2e864fbac3a12e475ebd1e5f030a3a437db6 (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
86
87
88
89
90
91
92
93
94
95
#
# Migration test scenario parameter description
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, see <http://www.gnu.org/licenses/>.
#


class Scenario(object):

    def __init__(self, name,
                 downtime=500,
                 bandwidth=125000, # 1000 gig-e, effectively unlimited
                 max_iters=30,
                 max_time=300,
                 pause=False, pause_iters=5,
                 post_copy=False, post_copy_iters=5,
                 auto_converge=False, auto_converge_step=10,
                 compression_mt=False, compression_mt_threads=1,
                 compression_xbzrle=False, compression_xbzrle_cache=10):

        self._name = name

        # General migration tunables
        self._downtime = downtime  # milliseconds
        self._bandwidth = bandwidth # MiB per second
        self._max_iters = max_iters
        self._max_time = max_time # seconds


        # Strategies for ensuring completion
        self._pause = pause
        self._pause_iters = pause_iters

        self._post_copy = post_copy
        self._post_copy_iters = post_copy_iters

        self._auto_converge = auto_converge
        self._auto_converge_step = auto_converge_step # percentage CPU time

        self._compression_mt = compression_mt
        self._compression_mt_threads = compression_mt_threads

        self._compression_xbzrle = compression_xbzrle
        self._compression_xbzrle_cache = compression_xbzrle_cache # percentage of guest RAM

    def serialize(self):
        return {
            "name": self._name,
            "downtime": self._downtime,
            "bandwidth": self._bandwidth,
            "max_iters": self._max_iters,
            "max_time": self._max_time,
            "pause": self._pause,
            "pause_iters": self._pause_iters,
            "post_copy": self._post_copy,
            "post_copy_iters": self._post_copy_iters,
            "auto_converge": self._auto_converge,
            "auto_converge_step": self._auto_converge_step,
            "compression_mt": self._compression_mt,
            "compression_mt_threads": self._compression_mt_threads,
            "compression_xbzrle": self._compression_xbzrle,
            "compression_xbzrle_cache": self._compression_xbzrle_cache,
        }

    @classmethod
    def deserialize(cls, data):
        return cls(
            data["name"],
            data["downtime"],
            data["bandwidth"],
            data["max_iters"],
            data["max_time"],
            data["pause"],
            data["pause_iters"],
            data["post_copy"],
            data["post_copy_iters"],
            data["auto_converge"],
            data["auto_converge_step"],
            data["compression_mt"],
            data["compression_mt_threads"],
            data["compression_xbzrle"],
            data["compression_xbzrle_cache"])