From 772d6853d26a4ab9f17c8aea865d6b69d3eb93c8 Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Mon, 17 Sep 2012 20:06:06 +0400 Subject: [PATCH] crtools: collect inet sockets to crtools 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 Signed-off-by: Pavel Emelyanov --- cr-restore.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/cr-restore.c b/cr-restore.c index d58b97040..71c8cdf4a 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -78,7 +78,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; @@ -88,13 +100,9 @@ static int prepare_shared(void) if (prepare_shmem_restore()) return -1; - if (prepare_shared_fdinfo()) - return -1; - if (prepare_shared_tty()) return -1; - if (collect_reg_files()) return -1; @@ -104,9 +112,6 @@ static int prepare_shared(void) if (collect_fifo()) return -1; - if (collect_inet_sockets()) - return -1; - if (collect_unix_sockets()) return -1; @@ -761,7 +766,7 @@ static int restore_task_with_children(void *_arg) if (mount_proc()) exit(-1); - if (prepare_shared()) + if (root_prepare_shared()) exit(-1); } @@ -951,6 +956,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);