2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

dump: Allocate root_item before run pre-dump scripts

This allows pre-dump scripts to know CT root_item pid
and enter into its namespaces.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Kirill Tkhai
2016-06-08 16:38:00 +03:00
committed by Pavel Emelyanov
parent b734cd4003
commit eec3f49b4d
3 changed files with 15 additions and 10 deletions

View File

@@ -1471,6 +1471,11 @@ int cr_pre_dump_tasks(pid_t pid)
int ret = -1;
LIST_HEAD(ctls);
root_item = alloc_pstree_item();
if (!root_item)
goto err;
root_item->pid.real = pid;
if (!opts.track_mem) {
pr_info("Enforcing memory tracking for pre-dump.\n");
opts.track_mem = true;
@@ -1505,7 +1510,7 @@ int cr_pre_dump_tasks(pid_t pid)
if (setup_alarm_handler())
goto err;
if (collect_pstree(pid))
if (collect_pstree())
goto err;
if (collect_pstree_ids_predump())
@@ -1616,6 +1621,11 @@ int cr_dump_tasks(pid_t pid)
pr_info("Dumping processes (pid: %d)\n", pid);
pr_info("========================================\n");
root_item = alloc_pstree_item();
if (!root_item)
goto err;
root_item->pid.real = pid;
pre_dump_ret = run_scripts(ACT_PRE_DUMP);
if (pre_dump_ret != 0) {
pr_err("Pre dump script failed with %d!\n", pre_dump_ret);
@@ -1668,7 +1678,7 @@ int cr_dump_tasks(pid_t pid)
* afterwards.
*/
if (collect_pstree(pid))
if (collect_pstree())
goto err;
if (collect_pstree_ids())

View File

@@ -1,7 +1,7 @@
#ifndef __CR_SEIZE_H__
#define __CR_SEIZE_H__
extern int collect_pstree(pid_t pid);
extern int collect_pstree(void);
extern void pstree_switch_state(struct pstree_item *root_item, int st);
extern const char *get_real_freezer_state(void);
extern bool alarm_timeouted(void);

View File

@@ -650,8 +650,9 @@ err_close:
return -1;
}
int collect_pstree(pid_t pid)
int collect_pstree(void)
{
pid_t pid = root_item->pid.real;
int ret = -1;
timing_start(TIME_FREEZING);
@@ -666,12 +667,6 @@ int collect_pstree(pid_t pid)
if (opts.freeze_cgroup && freeze_processes())
goto err;
root_item = alloc_pstree_item();
if (root_item == NULL)
goto err;
root_item->pid.real = pid;
if (!opts.freeze_cgroup && seize_catch_task(pid)) {
set_cr_errno(ESRCH);
goto err;