mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 15:25:21 +00:00
zdtm: add --criu-config option
The --criu-config option allows to run test with CRIU options provided via configuration files instead of command-line arguments. Suggested-by: Andrei Vagin <avagin@gmail.com> Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
committed by
Andrei Vagin
parent
fc38a01e5e
commit
d2073cd4d7
16
test/zdtm.py
16
test/zdtm.py
@@ -32,6 +32,7 @@ from builtins import input, int, open, range, str, zip
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import pycriu as crpc
|
import pycriu as crpc
|
||||||
|
from zdtm.criu_config import criu_config
|
||||||
|
|
||||||
# File to store content of streamed images
|
# File to store content of streamed images
|
||||||
STREAMED_IMG_FILE_NAME = "img.criu"
|
STREAMED_IMG_FILE_NAME = "img.criu"
|
||||||
@@ -1036,7 +1037,6 @@ class criu:
|
|||||||
self.__user = bool(opts['user'])
|
self.__user = bool(opts['user'])
|
||||||
self.__leave_stopped = bool(opts['stop'])
|
self.__leave_stopped = bool(opts['stop'])
|
||||||
self.__stream = bool(opts['stream'])
|
self.__stream = bool(opts['stream'])
|
||||||
self.__criu = (opts['rpc'] and criu_rpc or criu_cli)
|
|
||||||
self.__show_stats = bool(opts['show_stats'])
|
self.__show_stats = bool(opts['show_stats'])
|
||||||
self.__lazy_pages_p = None
|
self.__lazy_pages_p = None
|
||||||
self.__page_server_p = None
|
self.__page_server_p = None
|
||||||
@@ -1047,6 +1047,13 @@ class criu:
|
|||||||
self.__crit_bin = opts['crit_bin']
|
self.__crit_bin = opts['crit_bin']
|
||||||
self.__pre_dump_mode = opts['pre_dump_mode']
|
self.__pre_dump_mode = opts['pre_dump_mode']
|
||||||
|
|
||||||
|
if opts['rpc']:
|
||||||
|
self.__criu = criu_rpc
|
||||||
|
elif opts['criu_config']:
|
||||||
|
self.__criu = criu_config
|
||||||
|
else:
|
||||||
|
self.__criu = criu_cli
|
||||||
|
|
||||||
def fini(self):
|
def fini(self):
|
||||||
if self.__lazy_migrate:
|
if self.__lazy_migrate:
|
||||||
ret = self.__dump_process.wait()
|
ret = self.__dump_process.wait()
|
||||||
@@ -2024,8 +2031,8 @@ class Launcher:
|
|||||||
|
|
||||||
nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling',
|
nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling',
|
||||||
'stop', 'empty_ns', 'fault', 'keep_img', 'report', 'snaps',
|
'stop', 'empty_ns', 'fault', 'keep_img', 'report', 'snaps',
|
||||||
'sat', 'script', 'rpc', 'lazy_pages', 'join_ns', 'dedup', 'sbs',
|
'sat', 'script', 'rpc', 'criu_config', 'lazy_pages', 'join_ns',
|
||||||
'freezecg', 'user', 'dry_run', 'noauto_dedup',
|
'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
|
||||||
'remote_lazy_pages', 'show_stats', 'lazy_migrate', 'stream',
|
'remote_lazy_pages', 'show_stats', 'lazy_migrate', 'stream',
|
||||||
'tls', 'criu_bin', 'crit_bin', 'pre_dump_mode')
|
'tls', 'criu_bin', 'crit_bin', 'pre_dump_mode')
|
||||||
arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
|
arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
|
||||||
@@ -2647,6 +2654,9 @@ def get_cli_args():
|
|||||||
help="Run CRIU via RPC rather than CLI",
|
help="Run CRIU via RPC rather than CLI",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
|
||||||
|
rp.add_argument("--criu-config",
|
||||||
|
help="Use config file to set CRIU options",
|
||||||
|
action='store_true')
|
||||||
rp.add_argument("--page-server",
|
rp.add_argument("--page-server",
|
||||||
help="Use page server dump",
|
help="Use page server dump",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
0
test/zdtm/__init__.py
Normal file
0
test/zdtm/__init__.py
Normal file
42
test/zdtm/criu_config.py
Normal file
42
test/zdtm/criu_config.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
class criu_config:
|
||||||
|
@staticmethod
|
||||||
|
def run(action,
|
||||||
|
args,
|
||||||
|
criu_bin,
|
||||||
|
fault=None,
|
||||||
|
strace=[],
|
||||||
|
preexec=None,
|
||||||
|
nowait=False):
|
||||||
|
|
||||||
|
config_path = tempfile.mktemp(".conf", "criu-%s-" % action)
|
||||||
|
with open(config_path, "w") as config_fd:
|
||||||
|
for arg in args:
|
||||||
|
if arg.startswith("--"):
|
||||||
|
config_fd.write("\n")
|
||||||
|
arg = arg.strip("-")
|
||||||
|
config_fd.write("%s " % arg)
|
||||||
|
|
||||||
|
env = dict(
|
||||||
|
os.environ,
|
||||||
|
ASAN_OPTIONS="log_path=asan.log:disable_coredump=0:detect_leaks=0"
|
||||||
|
)
|
||||||
|
|
||||||
|
if fault:
|
||||||
|
print("Forcing %s fault" % fault)
|
||||||
|
env['CRIU_FAULT'] = fault
|
||||||
|
|
||||||
|
cr = subprocess.Popen(
|
||||||
|
strace +
|
||||||
|
[criu_bin, action, "--no-default-config", "--config", config_path],
|
||||||
|
env=env,
|
||||||
|
close_fds=False,
|
||||||
|
preexec_fn=preexec
|
||||||
|
)
|
||||||
|
if nowait:
|
||||||
|
return cr
|
||||||
|
return cr.wait()
|
Reference in New Issue
Block a user