2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

zdtm.py: add an option to change pycriu import path

By default zdtm expects that criu is built from source first and only
then you can run zdtm tests against it. But what if you really want to
run tests against a criu version installed on the system? Yes there is
already a nice option for zdtm to change the criu binary it uses
"--criu-bin", but it would still end up using the pycriu module from
source and you would still have to build everything beforehand.

Let's add an option to change the path where zdtm searches for pycriu
module "--pycriu-search-path". This way we can run zdtm tests on the
criu installed on the system directly without building criu from source,
e.g. on Fedora it works like:

test/zdtm.py run --criu-bin /usr/sbin/criu \
  --pycriu-search-path /usr/lib/python3.13/site-packages \
  -t zdtm/static/env00

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
Pavel Tikhomirov
2025-04-30 11:39:18 +08:00
committed by Radostin Stoyanov
parent 7c4bcdb2d4
commit 2da6a6faff

View File

@@ -22,11 +22,11 @@ import sys
import tempfile
import time
import uuid
import site
from builtins import input, int, open, range, str, zip
import yaml
import pycriu as crpc
from zdtm.criu_config import criu_config
# File to store content of streamed images
@@ -1142,6 +1142,24 @@ class criu:
self.__img_streamer_process = None
self.__tls = self.__tls_options() if opts['tls'] else []
self.__criu_bin = opts['criu_bin']
global crpc
pycriu_search_path = opts.get('pycriu_search_path')
if pycriu_search_path:
sys.path.insert(0, pycriu_search_path)
try:
import pycriu as crpc
if pycriu_search_path:
print(f"pycriu loaded from: {crpc.__file__}")
except ImportError:
if not pycriu_search_path:
print("Consider building CRIU or using '--pycriu-search-path' option.")
raise
finally:
if pycriu_search_path:
sys.path.pop(0)
self.__crit_bin = opts['crit_bin']
self.__pre_dump_mode = opts['pre_dump_mode']
self.__preload_libfault = bool(opts['preload_libfault'])
@@ -2169,7 +2187,8 @@ class Launcher:
'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
'remote_lazy_pages', 'show_stats', 'lazy_migrate', 'stream',
'tls', 'criu_bin', 'crit_bin', 'pre_dump_mode', 'mntns_compat_mode',
'rootless', 'preload_libfault', 'mocked_cuda_checkpoint')
'rootless', 'preload_libfault', 'mocked_cuda_checkpoint',
'pycriu_search_path')
arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
if self.__use_log:
@@ -2860,6 +2879,9 @@ def get_cli_args():
rp.add_argument("--criu-bin",
help="Path to criu binary",
default='../criu/criu')
rp.add_argument("--pycriu-search-path",
help=f"Path to search for pycriu module first (e.g., {site.getsitepackages()[0]})",
default=None)
rp.add_argument("--crit-bin",
help="Path to crit binary",
default='../crit/crit')