[CRIU] [PATCH 4/7] parasite: Introduce infect_ctx
Pavel Emelyanov
xemul at virtuozzo.com
Mon Sep 26 03:20:23 PDT 2016
This routine will become the part of compel A[PB]I and
will be given to user as configuration structure.
For now put there the pointer on a socket living in victim's
netns. Since CRIU creates such and generic compel user would
want compel to do it for him, this socket should be the
infect_ctx part.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/include/parasite-syscall.h | 6 ++++++
criu/parasite-syscall.c | 19 +++++++++++++------
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h
index c5db404..37bda6d 100644
--- a/criu/include/parasite-syscall.h
+++ b/criu/include/parasite-syscall.h
@@ -26,6 +26,10 @@ struct thread_ctx {
user_regs_struct_t regs;
};
+struct infect_ctx {
+ int *p_sock;
+};
+
/* parasite control block */
struct parasite_ctl {
struct pid pid;
@@ -34,6 +38,8 @@ struct parasite_ctl {
void *sigreturn_addr; /* A place for the breakpoint */
unsigned long map_length;
+ struct infect_ctx ictx;
+
/* thread leader data */
bool daemonized;
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index cf65c19..cebb740 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -445,7 +445,7 @@ static int restore_child_handler()
}
static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid,
- struct parasite_init_args *args, struct ns_id *net)
+ struct parasite_init_args *args)
{
static int ssock = -1;
@@ -453,8 +453,13 @@ static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid,
args->h_addr_len = gen_parasite_saddr(&args->h_addr, getpid());
if (ssock == -1) {
- ssock = net->net.seqsk;
- net->net.seqsk = -1;
+ ssock = *ctl->ictx.p_sock;
+ if (ssock == -1) {
+ pr_err("No socket in ictx\n");
+ goto err;
+ }
+
+ *ctl->ictx.p_sock = -1;
if (bind(ssock, (struct sockaddr *)&args->h_addr, args->h_addr_len) < 0) {
pr_perror("Can't bind socket");
@@ -498,7 +503,7 @@ static int accept_tsock(struct parasite_ctl *ctl)
return 0;
}
-static int parasite_init_daemon(struct parasite_ctl *ctl, struct ns_id *net)
+static int parasite_init_daemon(struct parasite_ctl *ctl)
{
struct parasite_init_args *args;
pid_t pid = ctl->pid.real;
@@ -514,7 +519,7 @@ static int parasite_init_daemon(struct parasite_ctl *ctl, struct ns_id *net)
futex_set(&args->daemon_connected, 0);
- if (prepare_tsock(ctl, pid, args, net))
+ if (prepare_tsock(ctl, pid, args))
goto err;
/* after this we can catch parasite errors in chld handler */
@@ -1437,7 +1442,7 @@ static int parasite_start_daemon(struct parasite_ctl *ctl, struct pstree_item *i
if (construct_sigframe(ctl->sigframe, ctl->rsigframe, item->core[0]))
return -1;
- if (parasite_init_daemon(ctl, dmpi(item)->netns))
+ if (parasite_init_daemon(ctl))
return -1;
return 0;
@@ -1477,6 +1482,8 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
if (!ctl)
return NULL;
+ ctl->ictx.p_sock = &dmpi(item)->netns->net.seqsk;
+
parasite_ensure_args_size(dump_pages_args_size(vma_area_list));
parasite_ensure_args_size(aio_rings_args_size(vma_area_list));
--
2.5.0
More information about the CRIU
mailing list