mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
ctrools: Rewrite task/threads stopping engine is back
This commit brings the former "Rewrite task/threads stopping engine" commit back. Handling it separately is too complex so better try to handle it in-place. Note some tests might fault, it's expected. --- Stopping tasks with STOP and proceeding with SEIZE is actually excessive -- the SEIZE if enough. Moreover, just killing a task with STOP is also racy, since task should be given some time to come to sleep before its proc can be parsed. Rewrite all this code to SEIZE task and all its threads from the very beginning. With this we can distinguish stopped task state and migrate it properly (not supported now, need to implement). This thing however has one BIG problem -- after we SEIZE-d a task we should seize it's threads, but we should do it in a loop -- reading /proc/pid/task and seizing them again and again, until the contents of this dir stops changing (not done now). Besides, after we seized a task and all its threads we cannot scan it's children list once -- task can get reparented to init and any task's child can call clone with CLONE_PARENT flag thus repopulating the children list of the already seized task (not done also) This patch is ugly, yes, but splitting it doesn't help to review it much, sorry :( Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
11
crtools.c
11
crtools.c
@@ -289,7 +289,7 @@ int main(int argc, char *argv[])
|
||||
int action = -1;
|
||||
int log_inited = 0;
|
||||
|
||||
static const char short_opts[] = "df:p:t:hcD:o:n:";
|
||||
static const char short_opts[] = "dsf:p:t:hcD:o:n:";
|
||||
|
||||
BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
|
||||
|
||||
@@ -306,6 +306,9 @@ int main(int argc, char *argv[])
|
||||
for (opt = getopt_long(argc - 1, argv + 1, short_opts, NULL, &idx); opt != -1;
|
||||
opt = getopt_long(argc - 1, argv + 1, short_opts, NULL, &idx)) {
|
||||
switch (opt) {
|
||||
case 's':
|
||||
opts.final_state = CR_TASK_STOP;
|
||||
break;
|
||||
case 'p':
|
||||
pid = atoi(optarg);
|
||||
opts.leader_only = true;
|
||||
@@ -316,7 +319,6 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case 'c':
|
||||
opts.show_pages_content = true;
|
||||
opts.final_state = CR_TASK_RUN;
|
||||
break;
|
||||
case 'f':
|
||||
opts.show_dump_file = optarg;
|
||||
@@ -398,10 +400,9 @@ usage:
|
||||
printk(" -p checkpoint/restore only a single process identified by pid\n");
|
||||
printk(" -t checkpoint/restore the whole process tree identified by pid\n");
|
||||
printk(" -f show contents of a checkpoint file\n");
|
||||
printk(" -c in case of checkpoint -- continue running the process after\n"
|
||||
" checkpoint complete, in case of showing file contents --\n"
|
||||
" show contents of pages dumped in hexdump format\n");
|
||||
printk(" -c show contents of pages dumped in hexdump format\n");
|
||||
printk(" -d detach after restore\n");
|
||||
printk(" -s leave tasks in stopped state after checkpoint instead of killing them\n");
|
||||
printk(" -n checkpoint/restore namespaces - values must be separated by comma\n");
|
||||
printk(" supported: uts, ipc\n");
|
||||
|
||||
|
Reference in New Issue
Block a user