[CRIU] [PATCH 18/78] infect: Make parasite_ctl private
Cyrill Gorcunov
gorcunov at openvz.org
Mon Nov 7 08:36:03 PST 2016
From: Pavel Emelyanov <xemul at virtuozzo.com>
This structure will be internal to compel. Users will only see
one as opaque pointer and read data from it using calls.
Exception for now -- infect_ictx. This is a configuration structure
that will be embeded into ctl and seen outside.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/arch/aarch64/crtools.c | 2 +-
criu/arch/arm/crtools.c | 2 +-
criu/arch/ppc64/crtools.c | 1 +
criu/arch/x86/crtools.c | 1 +
criu/cr-exec.c | 1 +
criu/include/infect-priv.h | 35 +++++++++++++++++++++++++++++++++++
criu/include/parasite-syscall.h | 34 +++++-----------------------------
criu/infect.c | 3 +++
criu/parasite-syscall.c | 9 ++++++++-
9 files changed, 56 insertions(+), 32 deletions(-)
create mode 100644 criu/include/infect-priv.h
diff --git a/criu/arch/aarch64/crtools.c b/criu/arch/aarch64/crtools.c
index 5510da19a7d0..5263dd0087ef 100644
--- a/criu/arch/aarch64/crtools.c
+++ b/criu/arch/aarch64/crtools.c
@@ -17,7 +17,7 @@
#include "util.h"
#include "cpu.h"
#include "restorer.h"
-
+#include "infect-priv.h"
/*
* Injected syscall instruction
diff --git a/criu/arch/arm/crtools.c b/criu/arch/arm/crtools.c
index 73a82b46aa76..6ca2fe3869f0 100644
--- a/criu/arch/arm/crtools.c
+++ b/criu/arch/arm/crtools.c
@@ -18,7 +18,7 @@
#include "restorer.h"
#include "errno.h"
#include "kerndat.h"
-
+#include "infect-priv.h"
/*
* Injected syscall instruction
diff --git a/criu/arch/ppc64/crtools.c b/criu/arch/ppc64/crtools.c
index 9e98190e0562..e4a27350c4eb 100644
--- a/criu/arch/ppc64/crtools.c
+++ b/criu/arch/ppc64/crtools.c
@@ -18,6 +18,7 @@
#include "util.h"
#include "cpu.h"
#include "errno.h"
+#include "infect-priv.h"
#include "protobuf.h"
#include "images/core.pb-c.h"
diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index e0eec9ec5642..39e3f5d8f24a 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -24,6 +24,7 @@
#include "errno.h"
#include "uapi/std/syscall-codes.h"
#include "kerndat.h"
+#include "infect-priv.h"
#include "protobuf.h"
#include "images/core.pb-c.h"
diff --git a/criu/cr-exec.c b/criu/cr-exec.c
index 718cb6cb5565..870017eb0f02 100644
--- a/criu/cr-exec.c
+++ b/criu/cr-exec.c
@@ -11,6 +11,7 @@
#include "util.h"
#include "kerndat.h"
#include "infect.h"
+#include "infect-priv.h"
struct syscall_exec_desc {
char *name;
diff --git a/criu/include/infect-priv.h b/criu/include/infect-priv.h
new file mode 100644
index 000000000000..a461ffa2ce9f
--- /dev/null
+++ b/criu/include/infect-priv.h
@@ -0,0 +1,35 @@
+#ifndef __COMPEL_INFECT_PRIV_H__
+#define __COMPEL_INFECT_PRIV_H__
+
+#include <stdbool.h>
+
+/* parasite control block */
+struct parasite_ctl {
+ int rpid; /* Real pid of the victim */
+ void *remote_map;
+ void *local_map;
+ void *sigreturn_addr; /* A place for the breakpoint */
+ unsigned long map_length;
+
+ struct infect_ctx ictx;
+
+ /* thread leader data */
+ bool daemonized;
+
+ struct thread_ctx orig;
+
+ void *rstack; /* thread leader stack*/
+ struct rt_sigframe *sigframe;
+ struct rt_sigframe *rsigframe; /* address in a parasite */
+
+ void *r_thread_stack; /* stack for non-leader threads */
+
+ unsigned long parasite_ip; /* service routine start ip */
+
+ unsigned int *addr_cmd; /* addr for command */
+ void *addr_args; /* address for arguments */
+ unsigned long args_size;
+ int tsock; /* transport socket for transferring fds */
+};
+
+#endif
diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h
index b70282fc205a..65d4217c2d86 100644
--- a/criu/include/parasite-syscall.h
+++ b/criu/include/parasite-syscall.h
@@ -46,34 +46,7 @@ struct infect_ctx {
#define INFECT_NO_MEMFD 0x1 /* don't use memfd() */
#define INFECT_FAIL_CONNECT 0x2 /* make parasite connect() fail */
-/* parasite control block */
-struct parasite_ctl {
- int rpid; /* Real pid of the victim */
- void *remote_map;
- void *local_map;
- void *sigreturn_addr; /* A place for the breakpoint */
- unsigned long map_length;
-
- struct infect_ctx ictx;
-
- /* thread leader data */
- bool daemonized;
-
- struct thread_ctx orig;
-
- void *rstack; /* thread leader stack*/
- struct rt_sigframe *sigframe;
- struct rt_sigframe *rsigframe; /* address in a parasite */
-
- void *r_thread_stack; /* stack for non-leader threads */
-
- unsigned long parasite_ip; /* service routine start ip */
-
- unsigned int *addr_cmd; /* addr for command */
- void *addr_args; /* address for arguments */
- unsigned long args_size;
- int tsock; /* transport socket for transferring fds */
-};
+struct parasite_ctl;
extern int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_imgset *cr_imgset);
extern int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct pstree_item *);
@@ -84,10 +57,13 @@ extern int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc
#define parasite_args(ctl, type) \
({ \
+ void *___ret; \
BUILD_BUG_ON(sizeof(type) > PARASITE_ARG_SIZE_MIN); \
- ctl->addr_args; \
+ ___ret = parasite_args_p(ctl); \
+ ___ret; \
})
+extern void *parasite_args_p(struct parasite_ctl *ctl);
extern void *parasite_args_s(struct parasite_ctl *ctl, int args_size);
extern int parasite_send_fd(struct parasite_ctl *ctl, int fd);
diff --git a/criu/infect.c b/criu/infect.c
index de48b428c63e..860525c92867 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -6,8 +6,11 @@
#include <signal.h>
#include <linux/seccomp.h>
+#include "parasite-syscall.h"
+
#include "log.h"
#include "infect.h"
+#include "infect-priv.h"
#define PTRACE_EVENT_STOP 128
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 241e0021eeb7..771bc3fbfec0 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -42,6 +42,8 @@
#include "restorer.h"
#include "pie/pie-relocs.h"
+#include "infect-priv.h"
+
#define MEMFD_FNAME "CRIUMFD"
#define MEMFD_FNAME_SZ sizeof(MEMFD_FNAME)
@@ -243,10 +245,15 @@ int __parasite_execute_syscall(struct parasite_ctl *ctl,
return err;
}
+void *parasite_args_p(struct parasite_ctl *ctl)
+{
+ return ctl->addr_args;
+}
+
void *parasite_args_s(struct parasite_ctl *ctl, int args_size)
{
BUG_ON(args_size > ctl->args_size);
- return ctl->addr_args;
+ return parasite_args_p(ctl);
}
static int parasite_run_in_thread(pid_t pid, unsigned int cmd,
--
2.7.4
More information about the CRIU
mailing list