Commit 51458d45 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

compel: plugins,std -- Move in infect code

Providing infect functionality inside std plugin
doesn't look suite for me: the restorer has to define
dummy parasite_daemon_cmd/parasite_trap_cmd/parasite_cleanup
just to be able to compile with it.

So we have to define weak stubs right here in near future.

travis-ci: success for compel: The final infect move and install target
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent a5106866
...@@ -50,6 +50,8 @@ target += std ...@@ -50,6 +50,8 @@ target += std
std-obj-y += std/std.o std-obj-y += std/std.o
std-obj-y += std/log.o std-obj-y += std/log.o
std-obj-y += std/string.o std-obj-y += std/string.o
std-obj-y += std/infect.o
std-obj-y += ./$(PLUGIN_ARCH_DIR)/std/parasite-head.o
include ./$(PLUGIN_ARCH_DIR)/std/syscalls/Makefile.syscalls include ./$(PLUGIN_ARCH_DIR)/std/syscalls/Makefile.syscalls
......
...@@ -4,5 +4,6 @@ ...@@ -4,5 +4,6 @@
#include <compel/plugins.h> #include <compel/plugins.h>
#include <compel/plugins/std/syscall.h> #include <compel/plugins/std/syscall.h>
#include <compel/plugins/std/string.h> #include <compel/plugins/std/string.h>
#include <compel/plugins/std/infect.h>
#endif /* COMPEL_PLUGIN_STD_STD_H__ */ #endif /* COMPEL_PLUGIN_STD_STD_H__ */
#ifndef COMPEL_PLUGIN_STD_INFECT_H__
#define COMPEL_PLUGIN_STD_INFECT_H__
extern int parasite_get_rpc_sock(void);
extern int parasite_service(unsigned int cmd, void *args);
/*
* Must be supplied by user plugins.
*/
extern int parasite_daemon_cmd(int cmd, void *args);
extern int parasite_trap_cmd(int cmd, void *args);
extern void parasite_cleanup(void);
/*
* FIXME: Should be supplied by log module.
*/
extern void log_set_fd(int fd);
extern void log_set_loglevel(unsigned int level);
#endif /* COMPEL_PLUGIN_STD_INFECT_H__ */
#include <compel/plugins/std/syscall.h>
#include <compel/plugins/std/infect.h>
#include "common/scm.h"
#include "uapi/compel/plugins/plugin-fds.h"
#include "uapi/compel/plugins/std/string.h"
#include "uapi/compel/plugins/std/log.h"
#include "common/compiler.h" #include "common/compiler.h"
#include "common/lock.h" #include "common/lock.h"
#include "int.h"
#include "util-pie.h"
#include <compel/plugins/std/log.h> #define pr_err(fmt, ...) print_on_level(1, fmt, ##__VA_ARGS__)
#include "criu-log.h" #define pr_info(fmt, ...) print_on_level(3, fmt, ##__VA_ARGS__)
#define pr_debug(fmt, ...) print_on_level(4, fmt, ##__VA_ARGS__)
#include "common/bug.h" #include "common/bug.h"
#include "sigframe.h"
#include "infect-rpc.h" #include "uapi/compel/asm/sigframe.h"
#include "infect-pie.h" #include "uapi/compel/infect-rpc.h"
#include "compel/include/rpc-pie-priv.h"
#include "rpc-pie-priv.h"
static int tsock = -1; static int tsock = -1;
...@@ -202,21 +211,3 @@ int __used __parasite_entry parasite_service(unsigned int cmd, void *args) ...@@ -202,21 +211,3 @@ int __used __parasite_entry parasite_service(unsigned int cmd, void *args)
return parasite_trap_cmd(cmd, args); return parasite_trap_cmd(cmd, args);
} }
/*
* Mainally, -fstack-protector is disabled for parasite.
* But we share some object files, compiled for CRIU with parasite.
* Those files (like cpu.c) may be compiled with stack protector
* support. We can't use gcc-ld provided stackprotector callback,
* as Glibc is unmapped. Let's just try to cure application in
* case of stack smashing in parasite.
*/
void __stack_chk_fail(void)
{
/*
* Smash didn't happen in printing part, as it's not shared
* with CRIU, therefore compiled with -fnostack-protector.
*/
pr_err("Stack smash detected in parasite\n");
fini();
}
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#define __sys(foo) foo #define __sys(foo) foo
#define __memcpy memcpy #define __memcpy memcpy
#define SCM_FDSET_HAS_OPTS
#include "common/scm.h" #include "common/scm.h"
#include "common/scm-code.c" #include "common/scm-code.c"
......
...@@ -59,7 +59,7 @@ criu/pie/native.lib.a: $(ARCH-LIB) ...@@ -59,7 +59,7 @@ criu/pie/native.lib.a: $(ARCH-LIB)
# #
# PIE code blobs themseves. # PIE code blobs themseves.
pie: criu/pie/native.lib.a pie: criu/pie/native.lib.a compel/plugins/std.built-in.o
$(Q) $(MAKE) $(build)=criu/pie all $(Q) $(MAKE) $(build)=criu/pie all
.PHONY: pie .PHONY: pie
......
...@@ -8,11 +8,11 @@ endif ...@@ -8,11 +8,11 @@ endif
compel_pack_lds-native := $(SRC_DIR)/compel/arch/$(ARCH)/scripts/compel-pack.lds.S compel_pack_lds-native := $(SRC_DIR)/compel/arch/$(ARCH)/scripts/compel-pack.lds.S
compel_pack_lds-compat := $(SRC_DIR)/compel/arch/$(ARCH)/scripts/compel-pack-compat.lds.S compel_pack_lds-compat := $(SRC_DIR)/compel/arch/$(ARCH)/scripts/compel-pack-compat.lds.S
compel_std-native := $(SRC_DIR)/compel/plugins/std.built-in.o
compel_std-compat := $(SRC_DIR)/compel/plugins/std-compat.built-in.o
native-obj-y += parasite.o native-obj-y += parasite.o
native-obj-y += infect.o
compat-obj-y += compat/parasite-compat.o compat-obj-y += compat/parasite-compat.o
compat-obj-y += compat/infect-compat.o
restorer-obj-y += restorer.o restorer-obj-y += restorer.o
restorer-obj-y += ./$(ARCH_DIR)/restorer.o restorer-obj-y += ./$(ARCH_DIR)/restorer.o
...@@ -25,18 +25,9 @@ ifeq ($(ARCH),x86) ...@@ -25,18 +25,9 @@ ifeq ($(ARCH),x86)
restorer-obj-y += ./$(ARCH_DIR)/sigaction_compat_pie.o restorer-obj-y += ./$(ARCH_DIR)/sigaction_compat_pie.o
endif endif
native-obj-y += ./$(ARCH_DIR)/parasite-head-64.o
native-obj-e += ./compel/plugins/std.built-in.o native-obj-e += ./compel/plugins/std.built-in.o
compat-obj-y += ./$(ARCH_DIR)/parasite-head-32.o compat-obj-e += ./compel/plugins/std-compat.built-in.o
compat-obj-e += ./compel/plugins/std-32.built-in.o
AFLAGS_parasite-head-64.o += -fpie -DCONFIG_X86_64
AFLAGS_parasite-head-64.d += -fpie -DCONFIG_X86_64
AFLAGS_parasite-head-32.o += -fno-pic -m32 -DCONFIG_X86_32
AFLAGS_parasite-head-32.d += -fno-pic -m32 -DCONFIG_X86_32
else else
native-obj-y += ./$(ARCH_DIR)/parasite-head.o
native-obj-e += ./compel/plugins/std.built-in.o native-obj-e += ./compel/plugins/std.built-in.o
restorer-obj-e += ./compel/plugins/std.built-in.o restorer-obj-e += ./compel/plugins/std.built-in.o
endif endif
...@@ -114,6 +105,7 @@ ifeq ($(strip $(V)),) ...@@ -114,6 +105,7 @@ ifeq ($(strip $(V)),)
piegen_stdout := >/dev/null piegen_stdout := >/dev/null
endif endif
$(obj)/restorer.built-in.o: $(compel_std-native)
$(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o \ $(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o \
$(obj)/native.lib.a $(compel_pack_lds-native) $(obj)/native.lib.a $(compel_pack_lds-native)
$(call msg-gen, $@) $(call msg-gen, $@)
...@@ -121,6 +113,7 @@ $(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o \ ...@@ -121,6 +113,7 @@ $(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o \
# $1 - binary mode: native/compat # $1 - binary mode: native/compat
define gen-rule-built-in.bin.o define gen-rule-built-in.bin.o
$(obj)/$(1).built-in.o: $(compel_std-$(1))
$(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o \ $(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o \
$(obj)/$(1).lib.a $(compel_pack_lds-$(1)) $(obj)/$(1).lib.a $(compel_pack_lds-$(1))
$$(call msg-gen, $$@) $$(call msg-gen, $$@)
...@@ -147,6 +140,7 @@ ifeq ($(filter arm aarch64,$(ARCH)),) ...@@ -147,6 +140,7 @@ ifeq ($(filter arm aarch64,$(ARCH)),)
endif endif
define gen-rule-built-in.bin.o define gen-rule-built-in.bin.o
$(obj)/$(1).built-in.o: $(compel_std-$(1))
$(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o \ $(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o \
$(compel_pack_lds-$(1)) $(obj)/native.lib.a $(compel_pack_lds-$(1)) $(obj)/native.lib.a
$$(call msg-gen, $$@) $$(call msg-gen, $$@)
...@@ -155,6 +149,7 @@ endef ...@@ -155,6 +149,7 @@ endef
$(eval $(call map,gen-rule-built-in.bin.o,$(parasite_target))) $(eval $(call map,gen-rule-built-in.bin.o,$(parasite_target)))
$(obj)/restorer.built-in.o: $(compel_std-native)
$(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o \ $(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o \
$(compel_pack_lds-native) $(obj)/native.lib.a $(compel_pack_lds-native) $(obj)/native.lib.a
$(call msg-gen, $@) $(call msg-gen, $@)
......
../infect.c
\ No newline at end of file
...@@ -63,11 +63,28 @@ static int n_helpers; ...@@ -63,11 +63,28 @@ static int n_helpers;
static pid_t *zombies; static pid_t *zombies;
static int n_zombies; static int n_zombies;
/*
* These are stubs for std compel plugin.
*/
int compel_main(void *arg_p, unsigned int arg_s) int compel_main(void *arg_p, unsigned int arg_s)
{ {
return 0; return 0;
} }
int parasite_daemon_cmd(int cmd, void *args)
{
return 0;
}
int parasite_trap_cmd(int cmd, void *args)
{
return 0;
}
void parasite_cleanup(void)
{
}
extern void cr_restore_rt (void) asm ("__cr_restore_rt") extern void cr_restore_rt (void) asm ("__cr_restore_rt")
__attribute__ ((visibility ("hidden"))); __attribute__ ((visibility ("hidden")));
......
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