Skip to content

Commit

Permalink
criu-ns: Add --criu-binary argument to run_criu()
Browse files Browse the repository at this point in the history
--criu-binary argument provides a way to supply the CRIU binary
location to run_criu().

Related to: #1909

Signed-off-by: Dhanuka Warusadura <csx@tuta.io>
  • Loading branch information
warusadura authored and avagin committed Oct 22, 2023
1 parent 3670953 commit 733f165
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/criu-ns
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,21 @@ def run_criu(args):
Spawn CRIU binary
"""
print(sys.argv)
os.execlp('criu', *['criu'] + args)
raise OSError(errno.ENOENT, "No such command")

if "--criu-binary" in args:
try:
opt_index = args.index("--criu-binary")
path = args[opt_index + 1]
del args[opt_index:opt_index + 2]
args.insert(0, "criu")
os.execv(path, args)
raise OSError(errno.ENOENT, "No such command")
except (ValueError, IndexError, FileNotFoundError):
raise OSError(errno.ENOENT, "--criu-binary missing argument")
else:
args.insert(0, "criu")
os.execvp("criu", args)
raise OSError(errno.ENOENT, "No such command")


# pidns_holder creates a process that is reparented to the init.
Expand Down

0 comments on commit 733f165

Please sign in to comment.