2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Andrei Vagin
3a3a3f0f27 image: use protoc instead of protoc-c
The new protoc 1.5.2 reports warnings:
`protoc-c` is deprecated. Please use `protoc` instead!

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2025-05-19 10:14:43 +01:00
Pavel Tikhomirov
0d15e2f4d9 zdtm: fix check for criu binary
The opts['action'] contains actor function and not the action name, so
we should compare it with a function.

While on it let's also add a comment about --criu-bin option if CRIU
binary is missing.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2025-05-19 10:14:18 +01:00
Pavel Tikhomirov
2da6a6faff 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>
2025-05-19 10:14:18 +01:00
6 changed files with 32 additions and 9 deletions

View File

@ -58,7 +58,7 @@ proto-obj-y += ext-file.o
proto-obj-y += cgroup.o
proto-obj-y += userns.o
proto-obj-y += pidns.o
proto-obj-y += google/protobuf/descriptor.o # To make protoc-c happy and compile opts.proto
proto-obj-y += google/protobuf/descriptor.o # To make protoc happy and compile opts.proto
proto-obj-y += opts.o
proto-obj-y += seccomp.o
proto-obj-y += binfmt-misc.o
@ -96,7 +96,7 @@ makefile-deps := Makefile $(obj)/Makefile
define gen-proto-rules
$(obj)/$(1).pb-c.c $(obj)/$(1).pb-c.h: $(obj)/$(1).proto $(addsuffix .pb-c.c,$(addprefix $(obj)/,$(2))) $(makefile-deps)
$$(E) " PBCC " $$@
$$(Q) protoc-c --proto_path=$(obj)/ --c_out=$(obj)/ $$<
$$(Q) protoc --proto_path=$(obj)/ --c_out=$(obj)/ $$<
ifeq ($(PROTOUFIX),y)
$$(Q) sed -i -e 's/4294967295/0xFFFFFFFF/g' $$@
$$(Q) sed -i -e 's/4294967295/0xFFFFFFFF/g' $$(patsubst %.c,%.h,$$@)

View File

@ -25,7 +25,7 @@ else
endif
criu-amdgpu.pb-c.c: criu-amdgpu.proto
protoc-c --proto_path=. --c_out=. criu-amdgpu.proto
protoc --proto_path=. --c_out=. criu-amdgpu.proto
amdgpu_plugin.so: amdgpu_plugin.c amdgpu_plugin_drm.c amdgpu_plugin_topology.c amdgpu_plugin_util.c criu-amdgpu.pb-c.c amdgpu_socket_utils.c
$(CC) $(PLUGIN_CFLAGS) $(shell $(COMPEL) includes) $^ -o $@ $(PLUGIN_INCLUDE) $(PLUGIN_LDFLAGS) $(LIBDRM_INC)

View File

@ -47,7 +47,7 @@ rpc_pb2.py: rpc.proto
protoc --proto_path=. --python_out=. rpc.proto
rpc.pb-c.c: rpc.proto
protoc-c --proto_path=. --c_out=. rpc.proto
protoc --proto_path=. --c_out=. rpc.proto
clean:
rm -rf build rpc.pb-c.o test-c.o test-c rpc.pb-c.c rpc.pb-c.h rpc_pb2.py rpc_pb2.pyc criu

View File

@ -4,7 +4,7 @@ run: all
./run.sh
unix.pb-c.c: unix.proto
protoc-c --proto_path=. --c_out=. unix.proto
protoc --proto_path=. --c_out=. unix.proto
unix-lib.so: unix-lib.c unix.pb-c.c
gcc -g -Werror -Wall -shared -nostartfiles unix-lib.c unix.pb-c.c -o unix-lib.so -iquote ../../../criu/include -fPIC

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'])
@ -1593,6 +1611,7 @@ class criu:
def available():
if not os.access(opts['criu_bin'], os.X_OK):
print("CRIU binary not found at %s" % opts['criu_bin'])
print("Consider building CRIU or using '--criu-bin' option.")
sys.exit(1)
def kill(self):
@ -2169,7 +2188,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 +2880,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')
@ -2950,7 +2973,7 @@ if __name__ == '__main__':
if opts['debug']:
sys.settrace(traceit)
if opts['action'] == 'run':
if opts['action'] == run_tests:
criu.available()
for tst in test_classes.values():
tst.available()

View File

@ -734,7 +734,7 @@ criu-rtc.pb-c.c: criu-rtc.proto
$(Q)echo $@ >> .gitignore
$(Q)echo $(@:%.c=%.h) >> .gitignore
$(E) " PBCC " $@
$(Q)protoc-c --proto_path=. --c_out=. criu-rtc.proto
$(Q)protoc --proto_path=. --c_out=. criu-rtc.proto
criu-rtc.so: criu-rtc.c criu-rtc.pb-c.c
$(E) " LD " $@