mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 05:48:05 +00:00
files: Create per-process transport sock and bind it
This will be used instead of currently existing per-fd transport sockets, which are used on receive_fd stage. v2: Create the socket before CR_STATE_FORKING state. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
d647f47f20
commit
c7eeef23e4
@ -267,10 +267,6 @@ static int root_prepare_shared(void)
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = open_transport_socket();
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
show_saved_files();
|
||||
err:
|
||||
return ret;
|
||||
@ -607,8 +603,6 @@ static int restore_one_alive_task(int pid, CoreEntry *core)
|
||||
if (prepare_vmas(current, ta))
|
||||
return -1;
|
||||
|
||||
close_service_fd(TRANSPORT_FD_OFF);
|
||||
|
||||
return sigreturn_restore(pid, ta, args_len, core);
|
||||
}
|
||||
|
||||
@ -1349,6 +1343,9 @@ static int restore_task_with_children(void *_arg)
|
||||
fini_restore_mntns();
|
||||
}
|
||||
|
||||
if (open_transport_socket())
|
||||
return -1;
|
||||
|
||||
if (restore_finish_stage(task_entries, CR_STATE_FORKING) < 0)
|
||||
goto err;
|
||||
|
||||
|
18
criu/files.c
18
criu/files.c
@ -1229,6 +1229,7 @@ int prepare_fds(struct pstree_item *me)
|
||||
break;
|
||||
}
|
||||
out_w:
|
||||
close_service_fd(TRANSPORT_FD_OFF);
|
||||
if (rsti(me)->fdt)
|
||||
futex_inc_and_wake(&rsti(me)->fdt->fdt_lock);
|
||||
out:
|
||||
@ -1663,15 +1664,28 @@ int inherit_fd_fini()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int open_transport_socket()
|
||||
int open_transport_socket(void)
|
||||
{
|
||||
int sock;
|
||||
struct fdt *fdt = rsti(current)->fdt;
|
||||
pid_t pid = current->pid.virt;
|
||||
struct sockaddr_un saddr;
|
||||
int sock, slen;
|
||||
|
||||
if (!task_alive(current) || (fdt && fdt->pid != pid))
|
||||
return 0;
|
||||
|
||||
sock = socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (sock < 0) {
|
||||
pr_perror("Can't create socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
transport_name_gen(&saddr, &slen, pid, -1);
|
||||
if (bind(sock, (struct sockaddr *)&saddr, slen) < 0) {
|
||||
pr_perror("Can't bind transport socket %s", saddr.sun_path + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (install_service_fd(TRANSPORT_FD_OFF, sock) < 0) {
|
||||
close(sock);
|
||||
return -1;
|
||||
|
@ -484,6 +484,9 @@ int clone_service_fd(int id)
|
||||
int old = __get_service_fd(i, service_fd_id);
|
||||
int new = __get_service_fd(i, id);
|
||||
|
||||
/* Do not dup parent's transport fd */
|
||||
if (i == TRANSPORT_FD_OFF)
|
||||
continue;
|
||||
ret = dup2(old, new);
|
||||
if (ret == -1) {
|
||||
if (errno == EBADF)
|
||||
|
Loading…
x
Reference in New Issue
Block a user