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

ipcns: 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 b895c73c
......@@ -3,7 +3,7 @@
#include "crtools.h"
extern int dump_ipc_ns(int ns_pid, const struct cr_fdset *fdset);
extern int dump_ipc_ns(int ns_pid, int ns_id);
extern int prepare_ipc_ns(int pid);
extern struct ns_desc ipc_ns_desc;
......
......@@ -455,20 +455,28 @@ static int dump_ipc_data(const struct cr_fdset *fdset)
return 0;
}
int dump_ipc_ns(int ns_pid, const struct cr_fdset *fdset)
int dump_ipc_ns(int ns_pid, int ns_id)
{
int ret;
struct cr_fdset *fdset;
fdset = cr_fdset_open(ns_id, _CR_FD_IPCNS_FROM, _CR_FD_IPCNS_TO, O_DUMP);
if (fdset == NULL)
return -1;
ret = switch_ns(ns_pid, &ipc_ns_desc, NULL);
if (ret < 0)
return ret;
goto err;
ret = dump_ipc_data(fdset);
if (ret < 0) {
pr_err("Failed to write IPC namespace data\n");
return ret;
goto err;
}
return 0;
err:
close_cr_fdset(&fdset);
return ret < 0 ? -1 : 0;
}
void ipc_sem_handler(int fd, void *obj)
......
......@@ -366,7 +366,7 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
}
if (ns_flags & CLONE_NEWIPC) {
pr_info("Dump IPC namespace\n");
ret = dump_ipc_ns(ns_pid->real, fdset);
ret = dump_ipc_ns(ns_pid->real, ns_id);
if (ret < 0)
goto err;
}
......
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