[CRIU] Re: [PATCH cr 8/8] cr-restore: unlock connections at the
last moment
Pavel Emelyanov
xemul at parallels.com
Fri Sep 14 07:27:26 EDT 2012
On 09/14/2012 02:25 PM, Andrey Vagin wrote:
> Restore must not fail after unlocking connections.
>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> cr-restore.c | 39 +++++++++++++++++++++++++++++----------
> sk-tcp.c | 2 --
> 2 files changed, 29 insertions(+), 12 deletions(-)
>
> diff --git a/cr-restore.c b/cr-restore.c
> index af962fe..888c488 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -835,6 +835,23 @@ static int restore_task_with_children(void *_arg)
> return restore_one_task(current->pid.virt);
> }
>
> +static int network_unlock_connections()
> +{
> + pr_info("Unlock network\n");
> + if (!(opts.namespaces_flags & CLONE_NEWNET)) {
> + tcp_unlock_connections();
> + return 0;
> + }
> +
> + if (opts.unlock_network == NULL)
> + return 0;
> +
> + if (system(opts.unlock_network))
> + return -1;
> +
> + return 0;
> +}
Same code exists in cr-dump.c
Let's move them both (merging, plus other guys) into net.c
> +
> static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
> {
> int ret;
> @@ -902,6 +919,18 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
> futex_wait_while_gt(&task_entries->nr_in_progress, 0);
> ret = (int)futex_get(&task_entries->nr_in_progress);
>
> + futex_set_and_wake(&task_entries->nr_in_progress, task_entries->nr);
> + futex_set_and_wake(&task_entries->start, CR_STATE_RESTORE_SIGCHLD);
> + futex_wait_until(&task_entries->nr_in_progress, 0);
> +
> + /* Restore SIGCHLD here to skip SIGCHLD from a network sctip */
> + ret = sigaction(SIGCHLD, &old_act, NULL);
> + if (ret < 0) {
> + pr_perror("sigaction() failed\n");
> + goto out;
> + }
> +
> + ret = network_unlock_connections();
> out:
> if (ret < 0) {
> struct pstree_item *pi;
> @@ -919,16 +948,6 @@ out:
> return 1;
> }
>
> - futex_set_and_wake(&task_entries->nr_in_progress, task_entries->nr);
> - futex_set_and_wake(&task_entries->start, CR_STATE_RESTORE_SIGCHLD);
> - futex_wait_until(&task_entries->nr_in_progress, 0);
> -
> - ret = sigaction(SIGCHLD, &old_act, NULL);
> - if (ret < 0) {
> - pr_perror("sigaction() failed\n");
> - return -1;
> - }
> -
> pr_info("Go on!!!\n");
> futex_set_and_wake(&task_entries->start, CR_STATE_COMPLETE);
>
> diff --git a/sk-tcp.c b/sk-tcp.c
> index ec4582e..ca36a0f 100644
> --- a/sk-tcp.c
> +++ b/sk-tcp.c
> @@ -547,8 +547,6 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii)
> if (rst_tcp_socks_add(fd))
> return -1;
>
> - nf_unlock_connection_info(ii);
> -
> if (restore_tcp_conn_state(fd, ii))
> return -1;
>
More information about the CRIU
mailing list