mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
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: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
c48bcbdb60
commit
634dd10b32
@@ -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();
|
||||
|
@@ -1,6 +1,9 @@
|
||||
#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 *);
|
||||
|
14
namespaces.c
14
namespaces.c
@@ -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) {
|
||||
|
Reference in New Issue
Block a user