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: checkpoint-restore#1909

Signed-off-by: Dhanuka Warusadura <csx@tuta.io>
  • Loading branch information
warusadura authored and avagin committed Oct 12, 2023
1 parent 8b0c67b commit a3884f1
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 a3884f1

Please sign in to comment.