Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum
OPTION_LSM_PROFILE,
OPTION_LSM_MOUNT_CONTEXT,
OPTION_NO_NEW_KEYRING,
OPTION_NO_SUBREAPER,
};

static char doc[] = "OCI runtime";
Expand Down Expand Up @@ -74,6 +75,7 @@ static struct argp_option options[]
{ "lsm-profile", OPTION_LSM_PROFILE, "VALUE", 0, "Specify an LSM profile to be used during restore in the form of TYPE:NAME", 0 },
{ "lsm-mount-context", OPTION_LSM_MOUNT_CONTEXT, "VALUE", 0, "Specify an LSM mount context to be used during restore", 0 },
{ "no-new-keyring", OPTION_NO_NEW_KEYRING, 0, 0, "keep the same session key", 0 },
{ "no-subreaper", OPTION_NO_SUBREAPER, 0, 0, "do not create a subreaper process (ignored)", 0 },
{
0,
} };
Expand Down Expand Up @@ -152,6 +154,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
libcrun_context_set_no_new_keyring (crun_context, true);
break;

case OPTION_NO_SUBREAPER:
break;

default:
return ARGP_ERR_UNKNOWN;
}
Expand All @@ -173,6 +178,10 @@ crun_command_restore (struct crun_global_arguments *global_args, int argc, char
cr_options.struct_size = sizeof (cr_options);
cr_options.manage_cgroups_mode = -1;

for (int i = 1; i < argc; i++)
if (strcmp (argv[i], "-no-subreaper") == 0)
argv[i] = "--no-subreaper";
Comment on lines +181 to +183

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it looks like a typo, better to fix it in containerd


argp_parse (&run_argp, argc, argv, ARGP_IN_ORDER, &first_arg, &cr_options);
crun_assert_n_args (argc - first_arg, 1, 2);

Expand Down
20 changes: 20 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,25 @@ def test_help_command():
return -1


def test_restore_no_subreaper_option():
"""Test restore accepts the no-subreaper flag spellings used by runtimes."""
if 'CRIU' not in get_crun_feature_string():
return (77, "crun built without CRIU support")

for option in ['--no-subreaper', '-no-subreaper']:
try:
run_crun_command_raw(['restore', option])
logger.info("restore unexpectedly succeeded without a container ID")
return -1
except subprocess.CalledProcessError as e:
output = e.output.decode('utf-8', errors='ignore').lower()
if 'please specify a id for the container' not in output:
logger.info("restore did not report a missing container ID for %s: %s", option, output)
return -1

return 0


all_tests = {
"pause-unpause": test_pause_unpause,
"kill-signal": test_kill_signal,
Expand All @@ -868,6 +887,7 @@ def test_help_command():
"start-command": test_start_command,
"version-command": test_version_command,
"help-command": test_help_command,
"restore-no-subreaper-option": test_restore_no_subreaper_option,
}

if __name__ == "__main__":
Expand Down