cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

scenario.py (3759B)


      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
     21class 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):
     34
     35        self._name = name
     36
     37        # General migration tunables
     38        self._downtime = downtime  # milliseconds
     39        self._bandwidth = bandwidth # MiB per second
     40        self._max_iters = max_iters
     41        self._max_time = max_time # seconds
     42
     43
     44        # Strategies for ensuring completion
     45        self._pause = pause
     46        self._pause_iters = pause_iters
     47
     48        self._post_copy = post_copy
     49        self._post_copy_iters = post_copy_iters
     50
     51        self._auto_converge = auto_converge
     52        self._auto_converge_step = auto_converge_step # percentage CPU time
     53
     54        self._compression_mt = compression_mt
     55        self._compression_mt_threads = compression_mt_threads
     56
     57        self._compression_xbzrle = compression_xbzrle
     58        self._compression_xbzrle_cache = compression_xbzrle_cache # percentage of guest RAM
     59
     60        self._multifd = multifd
     61        self._multifd_channels = multifd_channels
     62
     63    def serialize(self):
     64        return {
     65            "name": self._name,
     66            "downtime": self._downtime,
     67            "bandwidth": self._bandwidth,
     68            "max_iters": self._max_iters,
     69            "max_time": self._max_time,
     70            "pause": self._pause,
     71            "pause_iters": self._pause_iters,
     72            "post_copy": self._post_copy,
     73            "post_copy_iters": self._post_copy_iters,
     74            "auto_converge": self._auto_converge,
     75            "auto_converge_step": self._auto_converge_step,
     76            "compression_mt": self._compression_mt,
     77            "compression_mt_threads": self._compression_mt_threads,
     78            "compression_xbzrle": self._compression_xbzrle,
     79            "compression_xbzrle_cache": self._compression_xbzrle_cache,
     80            "multifd": self._multifd,
     81            "multifd_channels": self._multifd_channels,
     82        }
     83
     84    @classmethod
     85    def deserialize(cls, data):
     86        return cls(
     87            data["name"],
     88            data["downtime"],
     89            data["bandwidth"],
     90            data["max_iters"],
     91            data["max_time"],
     92            data["pause"],
     93            data["pause_iters"],
     94            data["post_copy"],
     95            data["post_copy_iters"],
     96            data["auto_converge"],
     97            data["auto_converge_step"],
     98            data["compression_mt"],
     99            data["compression_mt_threads"],
    100            data["compression_xbzrle"],
    101            data["compression_xbzrle_cache"],
    102            data["multifd"],
    103            data["multifd_channels"])