-
Couldn't load subscription status.
- Fork 670
pycriu: making images_dir_fd optional
#2798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
images_dir_fd optional
|
haven't tested lib/c, there might be the same issue |
|
current example of 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 google.protobuf.message.EncodeError: Message criu_req is missing required fields: opts.images_dir_fd |
lib/pycriu/criu.py
Outdated
| req = rpc.criu_req() | ||
| req.type = rpc.DUMP | ||
| req.opts.MergeFrom(self.opts) | ||
| req.opts.images_dir_fd = self.opts.images_dir_fd |
There was a problem hiding this comment.
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):
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, my bad
b5caafc to
48b28ad
Compare
|
@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]>
48b28ad to
132654a
Compare
|
#2789 Copies this PR. |
Since
images_dir_fdis a required filed inrpc.protowe mustexplicitly pass it into
optsin order to useimages_dir.Co-authored-by: Andrei Vagin [email protected]
Signed-off-by: Andrii Herheliuk [email protected]