mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
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: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
a51068664b
commit
51458d4518
@@ -50,6 +50,8 @@ target += std
|
||||
std-obj-y += std/std.o
|
||||
std-obj-y += std/log.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
|
||||
|
||||
|
@@ -4,5 +4,6 @@
|
||||
#include <compel/plugins.h>
|
||||
#include <compel/plugins/std/syscall.h>
|
||||
#include <compel/plugins/std/string.h>
|
||||
#include <compel/plugins/std/infect.h>
|
||||
|
||||
#endif /* COMPEL_PLUGIN_STD_STD_H__ */
|
||||
|
20
compel/plugins/include/uapi/std/infect.h
Normal file
20
compel/plugins/include/uapi/std/infect.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#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__ */
|
@@ -1,15 +1,24 @@
|
||||
#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/lock.h"
|
||||
#include "int.h"
|
||||
#include "util-pie.h"
|
||||
|
||||
#include <compel/plugins/std/log.h>
|
||||
#include "criu-log.h"
|
||||
#define pr_err(fmt, ...) print_on_level(1, fmt, ##__VA_ARGS__)
|
||||
#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 "sigframe.h"
|
||||
#include "infect-rpc.h"
|
||||
#include "infect-pie.h"
|
||||
#include "compel/include/rpc-pie-priv.h"
|
||||
|
||||
#include "uapi/compel/asm/sigframe.h"
|
||||
#include "uapi/compel/infect-rpc.h"
|
||||
|
||||
#include "rpc-pie-priv.h"
|
||||
|
||||
static int tsock = -1;
|
||||
|
||||
@@ -202,21 +211,3 @@ int __used __parasite_entry parasite_service(unsigned int cmd, void *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 @@
|
||||
#define __sys(foo) foo
|
||||
#define __memcpy memcpy
|
||||
|
||||
#define SCM_FDSET_HAS_OPTS
|
||||
|
||||
#include "common/scm.h"
|
||||
#include "common/scm-code.c"
|
||||
|
||||
|
@@ -59,7 +59,7 @@ criu/pie/native.lib.a: $(ARCH-LIB)
|
||||
|
||||
#
|
||||
# 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
|
||||
.PHONY: pie
|
||||
|
||||
|
@@ -8,11 +8,11 @@ endif
|
||||
|
||||
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_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 += infect.o
|
||||
compat-obj-y += compat/parasite-compat.o
|
||||
compat-obj-y += compat/infect-compat.o
|
||||
|
||||
restorer-obj-y += restorer.o
|
||||
restorer-obj-y += ./$(ARCH_DIR)/restorer.o
|
||||
@@ -25,18 +25,9 @@ ifeq ($(ARCH),x86)
|
||||
restorer-obj-y += ./$(ARCH_DIR)/sigaction_compat_pie.o
|
||||
endif
|
||||
|
||||
native-obj-y += ./$(ARCH_DIR)/parasite-head-64.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-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
|
||||
compat-obj-e += ./compel/plugins/std-compat.built-in.o
|
||||
else
|
||||
native-obj-y += ./$(ARCH_DIR)/parasite-head.o
|
||||
native-obj-e += ./compel/plugins/std.built-in.o
|
||||
restorer-obj-e += ./compel/plugins/std.built-in.o
|
||||
endif
|
||||
@@ -114,6 +105,7 @@ ifeq ($(strip $(V)),)
|
||||
piegen_stdout := >/dev/null
|
||||
endif
|
||||
|
||||
$(obj)/restorer.built-in.o: $(compel_std-native)
|
||||
$(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o \
|
||||
$(obj)/native.lib.a $(compel_pack_lds-native)
|
||||
$(call msg-gen, $@)
|
||||
@@ -121,6 +113,7 @@ $(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o \
|
||||
|
||||
# $1 - binary mode: native/compat
|
||||
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)/$(1).lib.a $(compel_pack_lds-$(1))
|
||||
$$(call msg-gen, $$@)
|
||||
@@ -147,6 +140,7 @@ ifeq ($(filter arm aarch64,$(ARCH)),)
|
||||
endif
|
||||
|
||||
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 \
|
||||
$(compel_pack_lds-$(1)) $(obj)/native.lib.a
|
||||
$$(call msg-gen, $$@)
|
||||
@@ -155,6 +149,7 @@ endef
|
||||
|
||||
$(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 \
|
||||
$(compel_pack_lds-native) $(obj)/native.lib.a
|
||||
$(call msg-gen, $@)
|
||||
|
@@ -1 +0,0 @@
|
||||
../infect.c
|
@@ -63,11 +63,28 @@ static int n_helpers;
|
||||
static pid_t *zombies;
|
||||
static int n_zombies;
|
||||
|
||||
/*
|
||||
* These are stubs for std compel plugin.
|
||||
*/
|
||||
int compel_main(void *arg_p, unsigned int arg_s)
|
||||
{
|
||||
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")
|
||||
__attribute__ ((visibility ("hidden")));
|
||||
|
||||
|
Reference in New Issue
Block a user