Commit cbe24fb9 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

compel: Move in parasite engine

This is the final patch in the series. It does a bunch
of renames and fixes headers respectively.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 51092282
......@@ -23,6 +23,11 @@ lib-y += src/lib/log.o
host-lib-y += src/lib/log.o
lib-y += arch/$(ARCH)/src/lib/cpu.o
lib-y += arch/$(ARCH)/src/lib/infect.o
lib-y += src/lib/infect-rpc.o
lib-y += src/lib/infect-util.o
lib-y += src/lib/infect.o
lib-y += src/lib/ptrace.o
ifeq ($(ARCH),x86)
lib-y += src/lib/handle-elf-32.o
......
#ifndef __COMPEL_PTRACE_H__
#define __COMPEL_PTRACE_H__
#ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
static inline int ptrace_set_breakpoint(pid_t pid, void *addr)
......
......@@ -7,8 +7,6 @@
#include <asm/ptrace.h>
#include "common/page.h"
#include "page.h"
#define SIGMAX 64
#define SIGMAX_OLD 31
......
......@@ -2,12 +2,10 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <linux/elf.h>
#include "asm/parasite-syscall.h"
#include <compel/plugins/std/syscall-codes.h>
#include "asm/types.h"
#include "criu-log.h"
#include "parasite-syscall.h"
#include "compel/include/errno.h"
#include "uapi/compel/asm/infect-types.h"
#include "log.h"
#include "errno.h"
#include "infect.h"
#include "infect-priv.h"
......
#ifndef __COMPEL_PTRACE_H__
#define __COMPEL_PTRACE_H__
#ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
static inline int ptrace_set_breakpoint(pid_t pid, void *addr)
......
......@@ -5,8 +5,6 @@
#include <sys/mman.h>
#include "common/page.h"
#include "page.h"
#define SIGMAX 64
#define SIGMAX_OLD 31
......
#ifndef UAPI_COMPEL_ASM_SIGFRAME_H__
#define UAPI_COMPEL_ASM_SIGFRAME_H__
#include <compel/asm/infect-types.h>
/* Copied from the Linux kernel header arch/arm/include/asm/sigcontext.h */
struct rt_sigcontext {
......
#include <sys/ptrace.h>
#include <sys/types.h>
#include "asm/parasite-syscall.h"
#include <compel/plugins/std/syscall-codes.h>
#include <compel/asm/processor-flags.h>
#include "asm/types.h"
#include "criu-log.h"
#include "parasite-syscall.h"
#include "compel/include/errno.h"
#include "uapi/compel/asm/infect-types.h"
#include "log.h"
#include "errno.h"
#include "infect.h"
#include "infect-priv.h"
......
#ifndef __COMPEL_PTRACE_H__
#define __COMPEL_PTRACE_H__
#ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP TRAP_BRKPT
static inline int ptrace_set_breakpoint(pid_t pid, void *addr)
......
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <stdint.h>
#include <errno.h>
#include <compel/plugins/std/syscall-codes.h>
#include "asm/types.h"
#include "ptrace.h"
#include "parasite-syscall.h"
#include "compel/include/errno.h"
#include "criu-log.h"
#include "uapi/compel/asm/infect-types.h"
#include "errno.h"
#include "log.h"
#include "common/bug.h"
#include "infect.h"
#include "infect-priv.h"
......@@ -22,7 +22,7 @@
/*
* Injected syscall instruction
*/
const u32 code_syscall[] = {
const uint32_t code_syscall[] = {
0x44000002, /* sc */
0x0fe00000 /* twi 31,0,0 */
};
......
#ifndef __COMPEL_PTRACE_H__
#define __COMPEL_PTRACE_H__
#ifndef __COMPEL_BREAKPOINTS_H__
#define __COMPEL_BREAKPOINTS_H__
#define ARCH_SI_TRAP SI_KERNEL
extern int ptrace_set_breakpoint(pid_t pid, void *addr);
extern int ptrace_flush_breakpoints(pid_t pid);
......
......@@ -11,15 +11,16 @@
#include <compel/asm/processor-flags.h>
#include <compel/cpu.h>
#include "compel/include/errno.h"
#include "errno.h"
#include <compel/plugins/std/syscall-codes.h>
#include <compel/plugins/std/syscall.h>
#include "compel/include/asm/ptrace.h"
#include "asm/ptrace.h"
#include "common/err.h"
#include "asm/infect-types.h"
#include "ptrace.h"
#include "uapi/compel/ptrace.h"
#include "infect.h"
#include "infect-priv.h"
#include "log.h"
/*
* Injected syscall instruction
......
......@@ -4,6 +4,8 @@
#include <errno.h>
#include <stdarg.h>
#include <compel/asm/infect-types.h>
#define COMPEL_TYPE_INT (1u << 0)
#define COMPEL_TYPE_LONG (1u << 1)
#define COMPEL_TYPE_GOTPCREL (1u << 2)
......@@ -22,4 +24,8 @@ typedef void (*compel_log_fn)(unsigned int lvl, const char *fmt, va_list parms);
extern void compel_log_init(compel_log_fn log_fn, unsigned int level);
extern unsigned int compel_log_get_loglevel(void);
#include <compel/infect-util.h>
#include <compel/infect-rpc.h>
#include <compel/infect.h>
#endif /* UAPI_COMPEL_H__ */
#ifndef __COMPEL_INFECT_H__
#define __COMPEL_INFECT_H__
#include "asm/infect-types.h"
#include <stdbool.h>
#include <compel/asm/sigframe.h>
#include <compel/asm/infect-types.h>
#include <compel/ksigset.h>
#include <compel/compel.h>
#include "common/compiler.h"
#define PARASITE_START_AREA_MIN (4096)
extern int compel_stop_task(int pid);
......
#ifndef __CR_PTRACE_H__
#define __CR_PTRACE_H__
#ifndef UAPI_COMPEL_PTRACE_H__
#define UAPI_COMPEL_PTRACE_H__
#include <linux/types.h>
#include <sys/ptrace.h>
#include "types.h"
#include <compel/asm/infect-types.h>
#include <compel/asm/breakpoints.h>
/* some constants for ptrace */
#ifndef PTRACE_SEIZE
......@@ -72,4 +73,4 @@ extern int ptrace_swap_area(pid_t pid, void *dst, void *src, long bytes);
extern int ptrace_get_regs(pid_t pid, user_regs_struct_t *regs);
extern int ptrace_set_regs(pid_t pid, user_regs_struct_t *regs);
#endif /* __CR_PTRACE_H__ */
#endif /* UAPI_COMPEL_PTRACE_H__ */
#include "int.h"
#include "log.h"
#include "common/bug.h"
#include "common/lock.h"
#include "util-pie.h"
#include "uapi/compel/plugins/plugin-fds.h"
#include "infect-rpc.h"
#include "infect-util.h"
......
......@@ -9,19 +9,20 @@
#include <fcntl.h>
#include <linux/seccomp.h>
#include "criu-log.h"
#include "log.h"
#include "common/bug.h"
#include "common/xmalloc.h"
#include "common/lock.h"
#include "common/page.h"
#include <compel/plugins/std/syscall-codes.h>
#include <compel/plugins/std/asm/syscall-types.h>
#include "compel/include/asm/ptrace.h"
#include "compel/include/asm/syscall.h"
#include "asm/ptrace.h"
#include "uapi/compel/plugins/std/syscall.h"
#include "asm/infect-types.h"
#include "asm/sigframe.h"
#include "infect.h"
#include "ptrace.h"
#include "uapi/compel/ptrace.h"
#include "infect-rpc.h"
#include "infect-priv.h"
#include "infect-util.h"
......@@ -495,7 +496,7 @@ int compel_execute_syscall(struct parasite_ctl *ctl,
{
pid_t pid = ctl->rpid;
int err;
u8 code_orig[BUILTIN_SYSCALL_SIZE];
uint8_t code_orig[BUILTIN_SYSCALL_SIZE];
/*
* Inject syscall instruction and remember original code,
......@@ -549,7 +550,7 @@ static int parasite_init_daemon(struct parasite_ctl *ctl)
args = compel_parasite_args(ctl, struct parasite_init_args);
args->sigframe = (uintptr_t)ctl->rsigframe;
args->log_level = log_get_loglevel();
args->log_level = compel_log_get_loglevel();
futex_set(&args->daemon_connected, 0);
......@@ -653,7 +654,7 @@ static int parasite_mmap_exchange(struct parasite_ctl *ctl, unsigned long size)
static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size)
{
void *where = (void *)ctl->ictx.syscall_ip + BUILTIN_SYSCALL_SIZE;
u8 orig_code[MEMFD_FNAME_SZ] = MEMFD_FNAME;
uint8_t orig_code[MEMFD_FNAME_SZ] = MEMFD_FNAME;
pid_t pid = ctl->rpid;
unsigned long sret = -ENOSYS;
int ret, fd, lfd;
......
......@@ -15,14 +15,12 @@
#include <sys/resource.h>
#include <sys/wait.h>
#include "int.h"
#include "common/compiler.h"
#include "util.h"
#include "ptrace.h"
#include "pid.h"
#include "proc_parse.h"
#include "seccomp.h"
#include "cr_options.h"
#include "uapi/compel/asm/infect-types.h"
#include "uapi/compel/ptrace.h"
#include "log.h"
int suspend_seccomp(pid_t pid)
{
......
......@@ -2,9 +2,6 @@ ccflags-y += -iquote criu/$(ARCH)
ccflags-y += -I compel/include/uapi
ccflags-y += -I compel/plugins/include/uapi
obj-y += infect.o
obj-y += infect-rpc.o
obj-y += infect-util.o
obj-y += action-scripts.o
obj-y += external.o
obj-y += aio.o
......@@ -58,7 +55,6 @@ obj-y += proc_parse.o
obj-y += protobuf-desc.o
obj-y += protobuf.o
obj-y += pstree.o
obj-y += ptrace.o
obj-y += rbtree.o
obj-y += rst-malloc.o
obj-y += seccomp.o
......
......@@ -11,8 +11,7 @@
#include "parasite.h"
#include "parasite-syscall.h"
#include "images/mm.pb-c.h"
#include "infect.h"
#include "infect-rpc.h"
#include <compel/compel.h>
#define NR_IOEVENTS_IN_NPAGES(npages) ((PAGE_SIZE * npages - sizeof(struct aio_ring)) / sizeof(struct io_event))
......
......@@ -11,4 +11,3 @@ obj-y += cpu.o
obj-y += crtools.o
obj-y += sigframe.o
obj-y += bitops.o
obj-y += infect.o
......@@ -6,10 +6,10 @@
#include "types.h"
#include <compel/asm/processor-flags.h>
#include "asm/infect-types.h"
#include <compel/asm/infect-types.h>
#include "asm/restorer.h"
#include "common/compiler.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "asm/dump.h"
#include "protobuf.h"
#include "images/core.pb-c.h"
......@@ -19,7 +19,7 @@
#include "util.h"
#include "cpu.h"
#include "restorer.h"
#include "infect.h"
#include <compel/compel.h>
#define assign_reg(dst, src, e) dst->e = (__typeof__(dst->e))(src)->e
......
#include "asm/types.h"
#include "asm/infect-types.h"
#include <compel/asm/infect-types.h>
#include "asm/sigframe.h"
int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe,
......
......@@ -12,4 +12,3 @@ obj-y += cpu.o
obj-y += crtools.o
obj-y += sigframe.o
obj-y += bitops.o
obj-y += infect.o
......@@ -4,11 +4,11 @@
#include "types.h"
#include <compel/asm/processor-flags.h>
#include "asm/infect-types.h"
#include <compel/asm/infect-types.h>
#include "asm/restorer.h"
#include "common/compiler.h"
#include "asm/dump.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "protobuf.h"
#include "images/core.pb-c.h"
#include "images/creds.pb-c.h"
......@@ -18,8 +18,8 @@
#include "elf.h"
#include "parasite-syscall.h"
#include "restorer.h"
#include "kerndat.h"
#include "infect.h"
#include <compel/compel.h>
#define assign_reg(dst, src, e) dst->e = (__typeof__(dst->e))((src)->ARM_##e)
......
#include "asm/types.h"
#include "asm/infect-types.h"
#include <compel/asm/infect-types.h>
#include "asm/sigframe.h"
int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe,
......
......@@ -8,4 +8,3 @@ ccflags-y += -I compel/plugins/include/uapi
obj-y += cpu.o
obj-y += crtools.o
obj-y += sigframe.o
obj-y += infect.o
......@@ -12,12 +12,12 @@
#include "cr_options.h"
#include "common/compiler.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "parasite-syscall.h"
#include "log.h"
#include "util.h"
#include "cpu.h"
#include "infect.h"
#include <compel/compel.h>
#include "protobuf.h"
#include "images/core.pb-c.h"
......
......@@ -5,7 +5,7 @@
#include <asm/elf.h>
#include <asm/types.h>
#include "asm/types.h"
#include "asm/infect-types.h"
#include <compel/asm/infect-types.h>
#include <compel/asm/sigframe.h>
......
......@@ -12,7 +12,6 @@ asflags-y += -iquote $(obj)/include
obj-y += cpu.o
obj-y += crtools.o
obj-y += sigframe.o
obj-y += infect.o
ifeq ($(CONFIG_COMPAT),y)
obj-y += sigaction_compat.o
obj-y += call32.o
......
......@@ -14,14 +14,14 @@
#include "cr_options.h"
#include "common/compiler.h"
#include "restorer.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "parasite-syscall.h"
#include "log.h"
#include "util.h"
#include "cpu.h"
#include <compel/plugins/std/syscall-codes.h>
#include "kerndat.h"
#include "infect.h"
#include <compel/compel.h>
#include "protobuf.h"
#include "images/core.pb-c.h"
......
#include "infect.h"
#include <compel/compel.h>
static struct syscall_exec_desc sc_exec_table_64[] = {
#include "sys-exec-tbl-64.c"
......
......@@ -38,7 +38,7 @@
#include "proc_parse.h"
#include "mount.h"
#include "tty.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "ptrace-compat.h"
#include "kerndat.h"
#include "timerfd.h"
......
......@@ -42,7 +42,6 @@
#include "cr_options.h"
#include "servicefd.h"
#include "string.h"
#include "ptrace.h"
#include "ptrace-compat.h"
#include "util.h"
#include "namespaces.h"
......
......@@ -12,8 +12,7 @@
#include "log.h"
#include "util.h"
#include "kerndat.h"
#include "infect.h"
#include "infect-priv.h"
#include <compel/compel.h>
struct syscall_exec_desc {
char *name;
......
......@@ -23,10 +23,8 @@
#include <sys/sendfile.h>
#include "compel/include/asm/ptrace.h"
#include "types.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "common/compiler.h"
#include "cr_options.h"
......@@ -71,7 +69,7 @@
#include "file-lock.h"
#include "action-scripts.h"
#include "shmem.h"
#include "infect.h"
#include <compel/compel.h>
#include "aio.h"
#include "lsm.h"
#include "seccomp.h"
......
......@@ -3,7 +3,7 @@
#include <sys/types.h>
#include "infect.h"
#include <compel/compel.h>
#include "images/seccomp.pb-c.h"
#define PROC_TASK_COMM_LEN 32
......
#ifndef __CR_PTRACE_ARCH_H__
#define __CR_PTRACE_ARCH_H__
#ifndef __CR_PTRACE_H__
#define __CR_PTRACE_H__
#include <linux/types.h>
#include <sys/ptrace.h>
#include "types.h"
#include "config.h"
#ifndef CONFIG_HAS_PTRACE_PEEKSIGINFO
......@@ -13,4 +15,4 @@ struct ptrace_peeksiginfo_args {
};
#endif
#endif /* __CR_PTRACE_ARCH_H__ */
#endif /* __CR_PTRACE_H__ */
#ifndef __CR_INC_TYPES_H__
#define __CR_INC_TYPES_H__
#include "asm/infect-types.h"
#include <compel/asm/infect-types.h>
#include "asm/types.h"
#endif
......@@ -25,9 +25,7 @@
#include "files-reg.h"
#include "pagemap-cache.h"
#include "fault-injection.h"
#include "infect.h"
#include "infect-rpc.h"
#include "infect-util.h"
#include <compel/compel.h>
#include "protobuf.h"
#include "images/pagemap.pb-c.h"
......
......@@ -15,7 +15,7 @@
#include "images/pagemap.pb-c.h"
#include "imgset.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "parasite-syscall.h"
#include "parasite.h"
#include "crtools.h"
......@@ -46,6 +46,8 @@
#include "infect-rpc.h"
#include "parasite-blob.h"
#include <compel/compel.h>
unsigned long get_exec_start(struct vm_area_list *vmas)
{
struct vma_area *vma_area;
......
......@@ -8,7 +8,7 @@
#include "sigframe.h"
#include "infect-rpc.h"
#include "infect-pie.h"
#include "rpc-pie-priv.h"
#include "compel/include/rpc-pie-priv.h"
static int tsock = -1;
......
......@@ -19,8 +19,6 @@
#include "criu-log.h"
#include "tty.h"
#include "aio.h"
#include "infect-rpc.h"
#include "infect-pie.h"
#include "asm/parasite.h"
#include "restorer.h"
......
......@@ -7,7 +7,7 @@
#include "imgset.h"
#include "kcmp.h"
#include "pstree.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "proc_parse.h"
#include "restorer.h"
#include "seccomp.h"
......
......@@ -15,13 +15,13 @@
#include "cr-errno.h"
#include "pstree.h"
#include "criu-log.h"
#include "ptrace.h"
#include <compel/ptrace.h>
#include "proc_parse.h"
#include "seize.h"
#include "stats.h"
#include "xmalloc.h"
#include "util.h"
#include "infect.h"
#include <compel/compel.h>
#define NR_ATTEMPTS 5
......
......@@ -19,8 +19,7 @@
#include "log.h"
#include "mem.h"
#include "vma.h"
#include "infect.h"
#include "infect-rpc.h"
#include <compel/compel.h>
#ifdef LOG_PREFIX
# undef LOG_PREFIX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment