Commit 84ebc64b authored by Pavel Emelyanov's avatar Pavel Emelyanov

pre-dump: Collect mount info, root and nsmask

Well, we want to pre-dump files (fsnotifies), for that we
will need mountinfo-s and root, and for the latter -- the
current ns mask.

The problem with current ns mask is that its generation is
incorporated into ns IDs generation and dumping. And since
the ids dumping is not performed on pre-dump, let's just
provide a helper for ns-mask generation.

Strictly speaking, the whole ns-mask idea is not great, but
it's to be fixed later.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c18c733b
......@@ -1630,6 +1630,15 @@ int cr_pre_dump_tasks(pid_t pid)
if (collect_pstree(pid))
goto err;
if (gen_predump_ns_mask())
goto err;
if (collect_mount_info(pid))
goto err;
if (mntns_collect_root(root_item->pid.real))
goto err;
for_each_pstree_item(item)
if (pre_dump_one_task(item, &ctls))
goto err;
......
......@@ -33,5 +33,6 @@ extern int switch_ns(int pid, struct ns_desc *nd, int *rst);
extern int restore_ns(int rst, struct ns_desc *nd);
extern int dump_task_ns_ids(struct pstree_item *);
extern int gen_predump_ns_mask(void);
#endif /* __CR_NS_H__ */
......@@ -353,6 +353,34 @@ int dump_task_ns_ids(struct pstree_item *item)
return 0;
}
static int gen_ns_ids(int pid)
{
/* needed for mntns_collect_root */
if (!get_ns_id(pid, &mnt_ns_desc))
return -1;
return 0;
}
/*
* We use ns_mask in various places to check whether
* the tasks we dump live in namespaces or not. The
* mask generation is tied with dumping inventory and
* tasks' images, which is not needed for pre-dump.
* This routine generates a mask for pre-dump.
*/
int gen_predump_ns_mask(void)
{
BUG_ON(current_ns_mask);
if (gen_ns_ids(getpid()))
return -1;
if (gen_ns_ids(root_item->pid.real))
return -1;
pr_info("NS mask generated: %lx\n", current_ns_mask);
return 0;
}
static int do_dump_namespaces(struct ns_id *ns)
{
int ret = -1;
......
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