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

netns: don't use global fdset for dumping namespace

We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 762d932c
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "list.h" #include "list.h"
struct cr_fdset; struct cr_fdset;
int dump_net_ns(int pid, struct cr_fdset *); int dump_net_ns(int pid, int ns_id);
int prepare_net_ns(int pid); int prepare_net_ns(int pid);
int netns_pre_create(void); int netns_pre_create(void);
......
...@@ -351,6 +351,7 @@ int dump_task_ns_ids(struct pstree_item *item) ...@@ -351,6 +351,7 @@ int dump_task_ns_ids(struct pstree_item *item)
static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags) static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
{ {
struct cr_fdset *fdset; struct cr_fdset *fdset;
pid_t ns_id = ns_pid->virt;
int ret = 0; int ret = 0;
fdset = cr_ns_fdset_open(ns_pid->virt, O_DUMP); fdset = cr_ns_fdset_open(ns_pid->virt, O_DUMP);
...@@ -377,7 +378,7 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags) ...@@ -377,7 +378,7 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
} }
if (ns_flags & CLONE_NEWNET) { if (ns_flags & CLONE_NEWNET) {
pr_info("Dump NET namespace info\n"); pr_info("Dump NET namespace info\n");
ret = dump_net_ns(ns_pid->real, fdset); ret = dump_net_ns(ns_pid->real, ns_id);
if (ret < 0) if (ret < 0)
goto err; goto err;
} }
......
...@@ -463,10 +463,15 @@ static int mount_ns_sysfs(void) ...@@ -463,10 +463,15 @@ static int mount_ns_sysfs(void)
return ns_sysfs_fd >= 0 ? 0 : -1; return ns_sysfs_fd >= 0 ? 0 : -1;
} }
int dump_net_ns(int pid, struct cr_fdset *fds) int dump_net_ns(int pid, int ns_id)
{ {
struct cr_fdset *fds;
int ret; int ret;
fds = cr_fdset_open(ns_id, _CR_FD_NETNS_FROM, _CR_FD_NETNS_TO, O_DUMP);
if (fds == NULL)
return -1;
ret = switch_ns(pid, &net_ns_desc, NULL); ret = switch_ns(pid, &net_ns_desc, NULL);
if (!ret) if (!ret)
ret = mount_ns_sysfs(); ret = mount_ns_sysfs();
...@@ -480,6 +485,7 @@ int dump_net_ns(int pid, struct cr_fdset *fds) ...@@ -480,6 +485,7 @@ int dump_net_ns(int pid, struct cr_fdset *fds)
close(ns_sysfs_fd); close(ns_sysfs_fd);
ns_sysfs_fd = -1; ns_sysfs_fd = -1;
close_cr_fdset(&fds);
return ret; return ret;
} }
......
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