xref: /openbmc/qemu/tests/migration/guestperf/progress.py (revision f3604191e296da90feb1b0bb24e986bc016809a8)
1409437e1SDaniel P. Berrange#
2409437e1SDaniel P. Berrange# Migration test migration operation progress
3409437e1SDaniel P. Berrange#
4409437e1SDaniel P. Berrange# Copyright (c) 2016 Red Hat, Inc.
5409437e1SDaniel P. Berrange#
6409437e1SDaniel P. Berrange# This library is free software; you can redistribute it and/or
7409437e1SDaniel P. Berrange# modify it under the terms of the GNU Lesser General Public
8409437e1SDaniel P. Berrange# License as published by the Free Software Foundation; either
93a645d36SGan Qixin# version 2.1 of the License, or (at your option) any later version.
10409437e1SDaniel P. Berrange#
11409437e1SDaniel P. Berrange# This library is distributed in the hope that it will be useful,
12409437e1SDaniel P. Berrange# but WITHOUT ANY WARRANTY; without even the implied warranty of
13409437e1SDaniel P. Berrange# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14409437e1SDaniel P. Berrange# Lesser General Public License for more details.
15409437e1SDaniel P. Berrange#
16409437e1SDaniel P. Berrange# You should have received a copy of the GNU Lesser General Public
17409437e1SDaniel P. Berrange# License along with this library; if not, see <http://www.gnu.org/licenses/>.
18409437e1SDaniel P. Berrange#
19409437e1SDaniel P. Berrange
20409437e1SDaniel P. Berrange
21409437e1SDaniel P. Berrangeclass ProgressStats(object):
22409437e1SDaniel P. Berrange
23409437e1SDaniel P. Berrange    def __init__(self,
24409437e1SDaniel P. Berrange                 transferred_bytes,
25409437e1SDaniel P. Berrange                 remaining_bytes,
26409437e1SDaniel P. Berrange                 total_bytes,
27409437e1SDaniel P. Berrange                 duplicate_pages,
28409437e1SDaniel P. Berrange                 skipped_pages,
29409437e1SDaniel P. Berrange                 normal_pages,
30409437e1SDaniel P. Berrange                 normal_bytes,
31409437e1SDaniel P. Berrange                 dirty_rate_pps,
32409437e1SDaniel P. Berrange                 transfer_rate_mbs,
33409437e1SDaniel P. Berrange                 iterations):
34409437e1SDaniel P. Berrange        self._transferred_bytes = transferred_bytes
35409437e1SDaniel P. Berrange        self._remaining_bytes = remaining_bytes
36409437e1SDaniel P. Berrange        self._total_bytes = total_bytes
37409437e1SDaniel P. Berrange        self._duplicate_pages = duplicate_pages
38409437e1SDaniel P. Berrange        self._skipped_pages = skipped_pages
39409437e1SDaniel P. Berrange        self._normal_pages = normal_pages
40409437e1SDaniel P. Berrange        self._normal_bytes = normal_bytes
41409437e1SDaniel P. Berrange        self._dirty_rate_pps = dirty_rate_pps
42409437e1SDaniel P. Berrange        self._transfer_rate_mbs = transfer_rate_mbs
43409437e1SDaniel P. Berrange        self._iterations = iterations
44409437e1SDaniel P. Berrange
45409437e1SDaniel P. Berrange    def serialize(self):
46409437e1SDaniel P. Berrange        return {
47409437e1SDaniel P. Berrange            "transferred_bytes": self._transferred_bytes,
48409437e1SDaniel P. Berrange            "remaining_bytes": self._remaining_bytes,
49409437e1SDaniel P. Berrange            "total_bytes": self._total_bytes,
50409437e1SDaniel P. Berrange            "duplicate_pages": self._duplicate_pages,
51409437e1SDaniel P. Berrange            "skipped_pages": self._skipped_pages,
52409437e1SDaniel P. Berrange            "normal_pages": self._normal_pages,
53409437e1SDaniel P. Berrange            "normal_bytes": self._normal_bytes,
54409437e1SDaniel P. Berrange            "dirty_rate_pps": self._dirty_rate_pps,
55409437e1SDaniel P. Berrange            "transfer_rate_mbs": self._transfer_rate_mbs,
56409437e1SDaniel P. Berrange            "iterations": self._iterations,
57409437e1SDaniel P. Berrange        }
58409437e1SDaniel P. Berrange
59409437e1SDaniel P. Berrange    @classmethod
60409437e1SDaniel P. Berrange    def deserialize(cls, data):
61409437e1SDaniel P. Berrange        return cls(
62409437e1SDaniel P. Berrange            data["transferred_bytes"],
63409437e1SDaniel P. Berrange            data["remaining_bytes"],
64409437e1SDaniel P. Berrange            data["total_bytes"],
65409437e1SDaniel P. Berrange            data["duplicate_pages"],
66409437e1SDaniel P. Berrange            data["skipped_pages"],
67409437e1SDaniel P. Berrange            data["normal_pages"],
68409437e1SDaniel P. Berrange            data["normal_bytes"],
69409437e1SDaniel P. Berrange            data["dirty_rate_pps"],
70409437e1SDaniel P. Berrange            data["transfer_rate_mbs"],
71409437e1SDaniel P. Berrange            data["iterations"])
72409437e1SDaniel P. Berrange
73409437e1SDaniel P. Berrange
74409437e1SDaniel P. Berrangeclass Progress(object):
75409437e1SDaniel P. Berrange
76409437e1SDaniel P. Berrange    def __init__(self,
77409437e1SDaniel P. Berrange                 status,
78409437e1SDaniel P. Berrange                 ram,
79409437e1SDaniel P. Berrange                 now,
80409437e1SDaniel P. Berrange                 duration,
81409437e1SDaniel P. Berrange                 downtime,
82409437e1SDaniel P. Berrange                 downtime_expected,
83409437e1SDaniel P. Berrange                 setup_time,
84*22b7cb2cSHyman Huang                 throttle_pcent,
85*22b7cb2cSHyman Huang                 dirty_limit_throttle_time_per_round,
86*22b7cb2cSHyman Huang                 dirty_limit_ring_full_time):
87409437e1SDaniel P. Berrange
88409437e1SDaniel P. Berrange        self._status = status
89409437e1SDaniel P. Berrange        self._ram = ram
90409437e1SDaniel P. Berrange        self._now = now
91409437e1SDaniel P. Berrange        self._duration = duration
92409437e1SDaniel P. Berrange        self._downtime = downtime
93409437e1SDaniel P. Berrange        self._downtime_expected = downtime_expected
94409437e1SDaniel P. Berrange        self._setup_time = setup_time
95409437e1SDaniel P. Berrange        self._throttle_pcent = throttle_pcent
96*22b7cb2cSHyman Huang        self._dirty_limit_throttle_time_per_round = \
97*22b7cb2cSHyman Huang            dirty_limit_throttle_time_per_round
98*22b7cb2cSHyman Huang        self._dirty_limit_ring_full_time = \
99*22b7cb2cSHyman Huang            dirty_limit_ring_full_time
100409437e1SDaniel P. Berrange
101409437e1SDaniel P. Berrange    def serialize(self):
102409437e1SDaniel P. Berrange        return {
103409437e1SDaniel P. Berrange            "status": self._status,
104409437e1SDaniel P. Berrange            "ram": self._ram.serialize(),
105409437e1SDaniel P. Berrange            "now": self._now,
106409437e1SDaniel P. Berrange            "duration": self._duration,
107409437e1SDaniel P. Berrange            "downtime": self._downtime,
108409437e1SDaniel P. Berrange            "downtime_expected": self._downtime_expected,
109409437e1SDaniel P. Berrange            "setup_time": self._setup_time,
110409437e1SDaniel P. Berrange            "throttle_pcent": self._throttle_pcent,
111*22b7cb2cSHyman Huang            "dirty_limit_throttle_time_per_round":
112*22b7cb2cSHyman Huang                self._dirty_limit_throttle_time_per_round,
113*22b7cb2cSHyman Huang            "dirty_limit_ring_full_time":
114*22b7cb2cSHyman Huang                self._dirty_limit_ring_full_time,
115409437e1SDaniel P. Berrange        }
116409437e1SDaniel P. Berrange
117409437e1SDaniel P. Berrange    @classmethod
118409437e1SDaniel P. Berrange    def deserialize(cls, data):
119409437e1SDaniel P. Berrange        return cls(
120409437e1SDaniel P. Berrange            data["status"],
121409437e1SDaniel P. Berrange            ProgressStats.deserialize(data["ram"]),
122409437e1SDaniel P. Berrange            data["now"],
123409437e1SDaniel P. Berrange            data["duration"],
124409437e1SDaniel P. Berrange            data["downtime"],
125409437e1SDaniel P. Berrange            data["downtime_expected"],
126409437e1SDaniel P. Berrange            data["setup_time"],
127*22b7cb2cSHyman Huang            data["throttle_pcent"],
128*22b7cb2cSHyman Huang            data["dirty_limit_throttle_time_per_round"],
129*22b7cb2cSHyman Huang            data["dirty_limit_ring_full_time"])
130