Skip to content

Conversation

@herheliuk
Copy link
Member

@herheliuk herheliuk commented Oct 23, 2025

Since images_dir_fd is a required filed in rpc.proto we must
explicitly pass it into opts in order to use images_dir.

Co-authored-by: Andrei Vagin [email protected]
Signed-off-by: Andrii Herheliuk [email protected]

@herheliuk herheliuk changed the title pycriu: making images_dir_fd optional pycriu: making images_dir_fd optional Oct 23, 2025
@herheliuk
Copy link
Member Author

haven't tested lib/c, there might be the same issue

@herheliuk
Copy link
Member Author

current example of images_dir usage:

from pycriu import criu as pycriu_criu

criu = pycriu_criu()

criu.opts.images_dir_fd = -1
criu.opts.images_dir = dumps_dir
criu.opts.pid = int(input('pid: '))
criu.opts.shell_job = True
criu.dump()

if we don't set criu.opts.images_dir_fd to -1:

google.protobuf.message.EncodeError: Message criu_req is missing required fields: opts.images_dir_fd

@herheliuk herheliuk marked this pull request as ready for review October 23, 2025 08:29
req = rpc.criu_req()
req.type = rpc.DUMP
req.opts.MergeFrom(self.opts)
req.opts.images_dir_fd = self.opts.images_dir_fd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be better to do something like that:

diff --git a/lib/pycriu/criu.py b/lib/pycriu/criu.py
index 5bd7ffecd..a496756d5 100644
--- a/lib/pycriu/criu.py
+++ b/lib/pycriu/criu.py
@@ -204,6 +204,9 @@ class criu:
     def __init__(self):
         self.use_binary('criu')
         self.opts = rpc.criu_opts()
+        # write a comment here why it is needed.
+        if self.opts.HasField("image_dir_fd"):
+          self.opts.images_dir_fd = -1
         self.sk = None
 
     def use_sk(self, sk_name):

Copy link
Member Author

@herheliuk herheliuk Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we can't do that, because we need to explicitly set images_dir_fd in req.opts not self.opts

P.S. CopyFrom(self.opts) doesn't work either, since it's a required field we need to pass it explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, my bad

@herheliuk herheliuk marked this pull request as draft October 23, 2025 19:23
@herheliuk herheliuk marked this pull request as ready for review October 23, 2025 19:26
@herheliuk herheliuk marked this pull request as draft October 23, 2025 19:37
@herheliuk
Copy link
Member Author

@avagin That's actually much better, thank you

Since `images_dir_fd` is a required filed in `rpc.proto` we must
explicitly pass it into `opts` in order to use `images_dir`.

Co-authored-by: Andrei Vagin <[email protected]>
Signed-off-by: Andrii Herheliuk <[email protected]>
@herheliuk herheliuk marked this pull request as ready for review October 23, 2025 20:00
@herheliuk
Copy link
Member Author

#2789 Copies this PR.

@herheliuk herheliuk closed this Oct 27, 2025
@herheliuk herheliuk deleted the fix-images-dir branch October 27, 2025 21:32
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.

2 participants