[CRIU] [PATCH cr 7/8] crtools: collect inet sockets to crtools
Andrey Vagin
avagin at openvz.org
Fri Sep 14 06:25:31 EDT 2012
Early we moved prepare_shared() to a root task,
because several preparation actions should be executed
in a target namespace set (e.g.: ghost files).
TCP sockets are a subset of init sockets,
they should be unlocked before resume. It's convient to do
from crtools.
An image can't be read more than one time, because we want to
send it via network.
For this two reasons prepare_shared is spitted in two parts,
one for crtools and one for a root task.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-restore.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 9fee16f..af962fe 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -77,7 +77,19 @@ static int shmem_remap(void *old_addr, void *new_addr, unsigned long size)
return 0;
}
-static int prepare_shared(void)
+static int crtools_prepare_shared(void)
+{
+ if (prepare_shared_fdinfo())
+ return -1;
+
+ /* Connections are unlocked from crtools */
+ if (collect_inet_sockets())
+ return -1;
+
+ return 0;
+}
+
+static int root_prepare_shared(void)
{
int ret = 0;
struct pstree_item *pi;
@@ -87,9 +99,6 @@ static int prepare_shared(void)
if (prepare_shmem_restore())
return -1;
- if (prepare_shared_fdinfo())
- return -1;
-
if (collect_reg_files())
return -1;
@@ -99,9 +108,6 @@ static int prepare_shared(void)
if (collect_fifo())
return -1;
- if (collect_inet_sockets())
- return -1;
-
if (collect_unix_sockets())
return -1;
@@ -772,7 +778,7 @@ static int restore_task_with_children(void *_arg)
if (mount_proc())
exit(-1);
- if (prepare_shared())
+ if (root_prepare_shared())
exit(-1);
}
@@ -960,6 +966,9 @@ int cr_restore_tasks(pid_t pid, struct cr_options *opts)
if (prepare_pstree_ids() < 0)
return -1;
+ if (crtools_prepare_shared() < 0)
+ return -1;
+
futex_set(&task_entries->nr_in_progress, task_entries->nr_tasks + task_entries->nr_helpers);
return restore_root_task(root_item, opts);
--
1.7.1
More information about the CRIU
mailing list