Commit 634dd10b authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

namespaces: dump_namespaces get a struct pid as argument

It uses pid for create image file and real_pid for dumping ns-s.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c48bcbdb
......@@ -1732,7 +1732,7 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
goto err;
if (opts->namespaces_flags)
if (dump_namespaces(pid, opts->namespaces_flags) < 0)
if (dump_namespaces(&root_item->pid, opts->namespaces_flags) < 0)
goto err;
ret = cr_dump_shmem();
......
#ifndef __CR_NS_H__
#define __CR_NS_H__
int dump_namespaces(int pid, unsigned int ns_flags);
#include "crtools.h"
int dump_namespaces(struct pid *pid, unsigned int ns_flags);
int prepare_namespace(int pid, unsigned long clone_flags);
struct cr_options;
int try_show_namespaces(int pid, struct cr_options *);
......
......@@ -31,30 +31,30 @@ out:
return ret;
}
static int do_dump_namespaces(int ns_pid, unsigned int ns_flags)
static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
{
struct cr_fdset *fdset;
int ret = 0;
fdset = cr_ns_fdset_open(ns_pid, O_DUMP);
fdset = cr_ns_fdset_open(ns_pid->pid, O_DUMP);
if (fdset == NULL)
return -1;
if (ns_flags & CLONE_NEWUTS) {
pr_info("Dump UTS namespace\n");
ret = dump_uts_ns(ns_pid, fdset);
ret = dump_uts_ns(ns_pid->real_pid, fdset);
if (ret < 0)
goto err;
}
if (ns_flags & CLONE_NEWIPC) {
pr_info("Dump IPC namespace\n");
ret = dump_ipc_ns(ns_pid, fdset);
ret = dump_ipc_ns(ns_pid->real_pid, fdset);
if (ret < 0)
goto err;
}
if (ns_flags & CLONE_NEWNS) {
pr_info("Dump MNT namespace (mountpoints)\n");
ret = dump_mnt_ns(ns_pid, fdset);
ret = dump_mnt_ns(ns_pid->real_pid, fdset);
if (ret < 0)
goto err;
}
......@@ -64,7 +64,7 @@ err:
}
int dump_namespaces(int ns_pid, unsigned int ns_flags)
int dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
{
int pid, status;
int ret = 0;
......@@ -80,7 +80,7 @@ int dump_namespaces(int ns_pid, unsigned int ns_flags)
* net namesapce with this is still open
*/
pr_info("Dumping %d's namespaces\n", ns_pid);
pr_info("Dumping %d(%d)'s namespaces\n", ns_pid->pid, ns_pid->real_pid);
pid = fork();
if (pid < 0) {
......
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