Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
34 changes: 33 additions & 1 deletion conmon/conmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static bool opt_systemd_cgroup = false;
static bool opt_no_pivot = false;
static char *opt_exec_process_spec = NULL;
static bool opt_exec = false;
static char *opt_restore_path = NULL;
static char *opt_log_path = NULL;
static char *opt_exit_dir = NULL;
static int opt_timeout = 0;
Expand All @@ -153,6 +154,7 @@ static GOptionEntry opt_entries[] =
{ "cid", 'c', 0, G_OPTION_ARG_STRING, &opt_cid, "Container ID", NULL },
{ "cuuid", 'u', 0, G_OPTION_ARG_STRING, &opt_cuuid, "Container UUID", NULL },
{ "runtime", 'r', 0, G_OPTION_ARG_STRING, &opt_runtime_path, "Runtime path", NULL },
{ "restore", 0, 0, G_OPTION_ARG_STRING, &opt_restore_path, "Restore a container from a checkpoint", NULL },
{ "no-new-keyring", 0, 0, G_OPTION_ARG_NONE, &opt_no_new_keyring, "Do not create a new session keyring for the container", NULL },
{ "no-pivot", 0, 0, G_OPTION_ARG_NONE, &opt_no_pivot, "Do not use pivot_root", NULL },
{ "replace-listen-pid", 0, 0, G_OPTION_ARG_NONE, &opt_replace_listen_pid, "Replace listen pid if set for oci-runtime pid", NULL },
Expand Down Expand Up @@ -1231,6 +1233,9 @@ int main(int argc, char *argv[])
exit(0);
}

if (opt_restore_path && opt_exec)
nexit("Cannot use 'exec' and 'restore' at the same time.");

if (opt_cid == NULL)
nexit("Container ID not provided. Use --cid");

Expand Down Expand Up @@ -1375,11 +1380,38 @@ int main(int argc, char *argv[])
"--pid-file", opt_pid_file,
NULL);
} else {
char *command;
if (opt_restore_path)
command = "restore";
else
command = "create";

add_argv(runtime_argv,
"create",
command,
"--bundle", opt_bundle_path,
"--pid-file", opt_pid_file,
NULL);

if (opt_restore_path) {
/*
* 'runc restore' is different from 'runc create'
* as the container is immediately running after
* a restore. Therefore the '--detach is needed'
* so that runc returns once the container is running.
*
* '--image-path' is the path to the checkpoint
* which will be become important when using pre-copy
* migration where multiple checkpoints can be created
* to reduce the container downtime during migration.
*
* '--work-path' is the directory CRIU will run in and
* also place its log files.
*/
add_argv(runtime_argv, "--detach",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will adding --detach prevent us from attaching to the container once it has been restored?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, those are different attaches. The podman attach is using the attach socket to talk to the container and that already works. I already tried it with registry.fedoraproject.org/f26/httpd and after a restore I can see the request to the httpd server being logged on podman attach -l

The runc restore --detach is that same detach as runc run --detach which will immediately return to the shell.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ack, just wanted to make sure

"--image-path", opt_restore_path,
"--work-path", opt_bundle_path,
NULL);
}
}

if (!opt_exec && opt_no_pivot) {
Expand Down