Commit e6a3aef4 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

remap: don't allocate dead pids in wrong context

Closes #87
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
CC: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 73a739b8
......@@ -132,6 +132,11 @@ static int crtools_prepare_shared(void)
if (collect_remaps_and_regfiles())
return -1;
/* dead pid remap needs to allocate task helpers which all tasks need
* to see */
if (prepare_procfs_remaps())
return -1;
/* Connections are unlocked from criu */
if (collect_inet_sockets())
return -1;
......
......@@ -361,7 +361,8 @@ static int prepare_one_remap(struct remap_info *ri)
ret = open_remap_ghost(rfi, rfe);
break;
case REMAP_TYPE__PROCFS:
ret = open_remap_dead_process(rfi, rfe);
/* handled earlier by prepare_procfs_remaps */
ret = 0;
break;
default:
pr_err("unknown remap type %u\n", rfe->remap_type);
......@@ -372,6 +373,31 @@ out:
return ret;
}
/* We separate the prepartion of PROCFS remaps because they allocate pstree
* items, which need to be seen by the root task. We can't do all remaps here,
* because the files haven't been loaded yet.
*/
int prepare_procfs_remaps(void)
{
struct remap_info *ri;
list_for_each_entry(ri, &remaps, list) {
RemapFilePathEntry *rfe = ri->rfe;
struct reg_file_info *rfi = ri->rfi;
switch (rfe->remap_type) {
case REMAP_TYPE__PROCFS:
if (open_remap_dead_process(rfi, rfe) < 0)
return -1;
break;
default:
continue;
}
}
return 0;
}
int prepare_remaps(void)
{
struct remap_info *ri;
......
......@@ -54,4 +54,6 @@ extern void try_clean_remaps(int ns_fd);
extern int strip_deleted(struct fd_link *link);
extern int prepare_procfs_remaps(void);
#endif /* __CR_FILES_REG_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment