[CRIU] [PATCH 05/11] uts: don't use global fdset for dumping namespace
Andrey Vagin
avagin at openvz.org
Mon Sep 30 06:16:47 PDT 2013
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: Andrey Vagin <avagin at openvz.org>
---
include/uts_ns.h | 2 +-
namespaces.c | 2 +-
uts_ns.c | 17 ++++++++++++-----
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/include/uts_ns.h b/include/uts_ns.h
index 792d43b..efb5165 100644
--- a/include/uts_ns.h
+++ b/include/uts_ns.h
@@ -3,7 +3,7 @@
#include "crtools.h"
-int dump_uts_ns(int ns_pid, struct cr_fdset *fdset);
+int dump_uts_ns(int ns_pid, int id);
int prepare_utsns(int pid);
extern struct ns_desc uts_ns_desc;
diff --git a/namespaces.c b/namespaces.c
index 84a6153..53029e4 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -360,7 +360,7 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
if (ns_flags & CLONE_NEWUTS) {
pr_info("Dump UTS namespace\n");
- ret = dump_uts_ns(ns_pid->real, fdset);
+ ret = dump_uts_ns(ns_pid->real, pid);
if (ret < 0)
goto err;
}
diff --git a/uts_ns.c b/uts_ns.c
index d09b546..00c9063 100644
--- a/uts_ns.c
+++ b/uts_ns.c
@@ -13,26 +13,33 @@
#include "protobuf.h"
#include "protobuf/utsns.pb-c.h"
-int dump_uts_ns(int ns_pid, struct cr_fdset *fdset)
+int dump_uts_ns(int ns_pid, int id)
{
- int ret;
+ int ret, img_fd;
struct utsname ubuf;
UtsnsEntry ue = UTSNS_ENTRY__INIT;
+ img_fd = open_image(CR_FD_UTSNS, O_DUMP, id);
+ if (img_fd < 0)
+ return -1;
+
ret = switch_ns(ns_pid, &uts_ns_desc, NULL);
if (ret < 0)
- return ret;
+ goto err;
ret = uname(&ubuf);
if (ret < 0) {
pr_perror("Error calling uname");
- return ret;
+ goto err;
}
ue.nodename = ubuf.nodename;
ue.domainname = ubuf.domainname;
- return pb_write_one(fdset_fd(fdset, CR_FD_UTSNS), &ue, PB_UTSNS);
+ ret = pb_write_one(img_fd, &ue, PB_UTSNS);
+err:
+ close(img_fd);
+ return ret < 0 ? -1 : 0;
}
int prepare_utsns(int pid)
--
1.8.3.1
More information about the CRIU
mailing list