[CRIU] [PATCH 7/9] unix: Move shared data init into early stage
Cyrill Gorcunov
gorcunov at gmail.com
Sat Jun 9 16:26:09 MSK 2018
We will need to take mutex when bind()
bindmounted sockets. Strictly speaking we
won't support bindmounted and deleted sockets
for now but better prepare this scaffolds early.
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
criu/cr-restore.c | 3 +++
criu/include/sockets.h | 1 +
criu/sk-unix.c | 10 +++++++---
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index e1571a6ed4d5..94ac242956f6 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -257,6 +257,9 @@ static int crtools_prepare_shared(void)
if (prepare_cgroup())
return -1;
+ if (unix_prepare_shared())
+ return -1;
+
return 0;
}
diff --git a/criu/include/sockets.h b/criu/include/sockets.h
index d278f52b628c..8df7b70da9a7 100644
--- a/criu/include/sockets.h
+++ b/criu/include/sockets.h
@@ -62,6 +62,7 @@ extern int netlink_receive_one(struct nlmsghdr *hdr, struct ns_id *ns, void *arg
extern int unix_sk_id_add(unsigned int ino);
extern int unix_sk_ids_parse(char *optarg);
extern int unix_prepare_root_shared(void);
+extern int unix_prepare_shared(void);
extern int do_dump_opt(int sk, int level, int name, void *val, int len);
#define dump_opt(s, l, n, f) do_dump_opt(s, l, n, f, sizeof(*f))
diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index d1a97759966d..5fd6fc73f841 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -2138,16 +2138,20 @@ static int init_unix_sk_info(struct unix_sk_info *ui, UnixSkEntry *ue)
return 0;
}
-int unix_prepare_root_shared(void)
+int unix_prepare_shared(void)
{
- struct unix_sk_info *ui;
-
mutex_ghost = shmalloc(sizeof(*mutex_ghost));
if (!mutex_ghost) {
pr_err("ghost: Can't allocate mutex\n");
return -ENOMEM;
}
mutex_init(mutex_ghost);
+ return 0;
+}
+
+int unix_prepare_root_shared(void)
+{
+ struct unix_sk_info *ui;
pr_debug("ghost: Resolving addresses\n");
--
2.14.4
More information about the CRIU
mailing list