Commit 07216269 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

namespaces: dump mount namespaces before tasks (v2)

because we want to check, that all files are reachable.
For that we need to collect all mounts from all namespaces.

v2: dump mntns separately
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c51e91f6
......@@ -1757,6 +1757,9 @@ int cr_dump_tasks(pid_t pid)
if (!glob_fdset)
goto err;
if (dump_mnt_namespaces() < 0)
goto err;
for_each_pstree_item(item) {
if (dump_one_task(item))
goto err;
......
......@@ -35,6 +35,7 @@ extern unsigned long root_ns_mask;
extern const struct fdtype_ops nsfile_dump_ops;
extern struct collect_image_info nsfile_cinfo;
extern int dump_mnt_namespaces(void);
extern int dump_namespaces(struct pstree_item *item, unsigned int ns_flags);
extern int prepare_namespace(struct pstree_item *item, unsigned long clone_flags);
extern int try_show_namespaces(int pid);
......
......@@ -419,6 +419,7 @@ static int do_dump_namespaces(struct ns_id *ns)
switch (ns->nd->cflag) {
case CLONE_NEWPID:
case CLONE_NEWNS:
ret = 0;
break;
case CLONE_NEWUTS:
......@@ -431,11 +432,6 @@ static int do_dump_namespaces(struct ns_id *ns)
ns->id, ns->pid);
ret = dump_ipc_ns(ns->pid, ns->id);
break;
case CLONE_NEWNS:
pr_info("Dump MNT namespace (mountpoints) %d via %d\n",
ns->id, ns->pid);
ret = dump_mnt_ns(ns->pid, ns->id);
break;
case CLONE_NEWNET:
pr_info("Dump NET namespace info %d via %d\n",
ns->id, ns->pid);
......@@ -450,6 +446,29 @@ static int do_dump_namespaces(struct ns_id *ns)
}
int dump_mnt_namespaces(void)
{
struct ns_id *ns;
int ret = 0;
for (ns = ns_ids; ns; ns = ns->next) {
/* Skip current namespaces, which are in the list too */
if (ns->pid == getpid())
continue;
if (!(ns->nd->cflag & CLONE_NEWNS))
continue;
pr_info("Dump MNT namespace (mountpoints) %d via %d\n",
ns->id, ns->pid);
ret = dump_mnt_ns(ns->pid, ns->id);
if (ret)
break;
}
return ret;
}
int dump_namespaces(struct pstree_item *item, unsigned int ns_flags)
{
struct pid *ns_pid = &item->pid;
......
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