Skip to content

Conversation

@rst0git
Copy link
Member

@rst0git rst0git commented Oct 20, 2025

The check() functionality is very different from dump, pre-dump, and restore. It is used only to check if the kernel supports required features, and does not need the majority of options set via RPC.

This patch updates the RPC options parser so that it only handles the logging options when check() is used. In particular, logging to a file is required when log_file is explicitly set or no log_to_stderr is used. In such case, we also resolve images_dir and work_dir where the log file will be created.

Fixes: #2758

@herheliuk
Copy link
Member

@rst0git Thank you very much!

@herheliuk
Copy link
Member

herheliuk commented Oct 25, 2025

@rst0git Thank you for giving me credit!

Github doesn't seem to recognise 'Co-developed-by' tag.

Would you mind using tag 'Co-authored-by' in b64a362 and c2e1a88 instead?

@rst0git rst0git force-pushed the cr-service-check branch 2 times, most recently from df6f7da to 8468539 Compare October 26, 2025 12:11
@herheliuk
Copy link
Member

herheliuk commented Oct 26, 2025

@rst0git I'm sorry, but you forged my signature for f1fe4d7 and a18d0b0 commits.

Your solution with pre-populating opts with images_dir_fd seems interesting, but
I would not sign it for reasons described earlier (technical debt).

Using 'Co-authored-by' instead would be greatly appreciated. Thank you.

@rst0git
Copy link
Member Author

rst0git commented Oct 26, 2025

@herheliuk No worries, I was just trying to give you credit for working on this.

@herheliuk
Copy link
Member

herheliuk commented Oct 28, 2025

This PR is pure MAGIC! ✨🚀 (Maybe 49e9de0 has also played in this, idk)

But now I can self-dump with pycriu using use_binary!

sudo -E $(which python) test.py (I'm using a fork)

from os import makedirs as os_makedirs
os_makedirs('criu_dumps', exist_ok=True)

from pycriu import criu as pycriu_criu

criu = pycriu_criu()

criu.opts.images_dir = 'criu_dumps'
criu.opts.shell_job = True

criu.dump()

Can't self-restore using use_binary, but we'll get there 😅

Awesome work, @rst0git

Thank you very much!

@rst0git
Copy link
Member Author

rst0git commented Oct 28, 2025

Could you please move Co-authored-by: Andrii Herheliuk [email protected] from 6fc5266 to 5d258c5 ?

@herheliuk I'm not sure if this would be correct. 6fc5266 used to be similar to the patch in #2796. I addressed Andrei's comment above and the patch looks different but the commit message is still very similar.

@herheliuk
Copy link
Member

You're right, it's all good as it is now. Thank you.

@rst0git rst0git force-pushed the cr-service-check branch 2 times, most recently from 522d349 to 4db71ea Compare October 28, 2025 20:31
@rst0git rst0git changed the title cr-service: don't require criu_opts for check() cr-service: refactor RPC opts parsing for check() Oct 28, 2025
herheliuk and others added 5 commits October 28, 2025 21:12
This change allows users to call criu.use_sk() without any
parameters to use the default socket name.

Co-authored-by: Radostin Stoyanov <[email protected]>
Signed-off-by: Andrii Herheliuk <[email protected]>
Move the code that opens the images directory, resolves its absolute
path via readlink(), selects the work_dir, and chdir()s into it into a
new function: setup_images_and_workdir(). This reduces the size of
`setup_opts_from_req()`, improves its readability, and allows this
functionality to be reused.

While at it, change open_image_dir() to take a const char *dir
parameter, reflecting that the path is not modified by the function and
allowing callers to pass string literals without casts.

No functional changes are intended.

Signed-off-by: Radostin Stoyanov <[email protected]>
Commit 9089ce8 ("service: use setproctitle") extended cr-service to
get the full path of images_dir using readlink(). However, the RPC
API was later extended to allow setting a custom path (folder) to
be set instead of passing a file descriptor, which causes readlink()
to fail as the path is not a symbolic link.

It would be better to drop the code setting the images-dir path as a
string in the proctitle.

Fixes: checkpoint-restore#2794

Suggested-by: Andrei Vagin <[email protected]>
Co-authored-by: Andrii Herheliuk <[email protected]>
Signed-off-by: Radostin Stoyanov <[email protected]>
Move the images_dir selection logic from setup_opts_from_req() into a
new function: resolve_images_dir_path(). This improves readability and
allows the code to be reused. While at it, use snprintf() instead of
sprintf() for the /proc path and ensure NULL termination after strncpy().

Signed-off-by: Radostin Stoyanov <[email protected]>
Move the logging initialization into a helper function that
can be reused.

No functional change intended.

Signed-off-by: Radostin Stoyanov <[email protected]>
@rst0git rst0git force-pushed the cr-service-check branch 2 times, most recently from 45eb439 to e187cc8 Compare October 28, 2025 21:26
@avagin
Copy link
Member

avagin commented Oct 28, 2025

please don't merge unrelated patches to one pull request. It is much easier to review smaller pr-s

rst0git and others added 6 commits October 29, 2025 06:26
The check() functionality is very different from dump, pre-dump,
and restore. It is used only to check if the kernel supports required
features, and does not need the majority of options set via RPC.

In particular, we don't need to open `image_dir` when running `check()`
because this functionality doesn't create or process image files. In
this case, `image_dir` is used as `work_dir`, only when the latter is
not specified and a log file is used.

This patch updates the RPC options parser so that it only handles the
logging options when check() is used. Logging to a file is required when
log_file is explicitly set or no log_to_stderr is used. In such case, we
also resolve images_dir and work_dir where the log file will be created.

Fixes: checkpoint-restore#2758

Suggested-by: Andrei Vagin <[email protected]>
Signed-off-by: Radostin Stoyanov <[email protected]>
This allows users to specify RPC options when
using the check() functionality.

Co-authored-by: Andrii Herheliuk <[email protected]>
Signed-off-by: Radostin Stoyanov <[email protected]>
_init__.py defines the public API for pycriu. It is important to use
explicit imports to avoid leaking every symbol from criu.py into the
pycriu namespace. This avoids import-time side effects, prevents name
collisions, and circular-import traps.

Fixes the following lint error:
  F403 `from .criu import *` used; unable to detect undefined names

Signed-off-by: Radostin Stoyanov <[email protected]>
The --mntns-compat-mode option is no longer parsed with CHECK.
Use --log-file instead to test the error message.

Signed-off-by: Radostin Stoyanov <[email protected]>
@rst0git
Copy link
Member Author

rst0git commented Oct 29, 2025

please don't merge unrelated patches to one pull request. It is much easier to review smaller pr-s

Sorry about this! I've extended make lint to check the new test files as well as lib/pycriu/__init__.py and lib/pycriu/criu.py. This created a merge conflict with #2806. The other patches are needed for the tests to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pycriu check always errors

3 participants