[CRIU] [PATCH 1/3] compel: Add fds plugin

Pavel Emelyanov xemul at virtuozzo.com
Mon Mar 6 08:40:12 PST 2017


This is just export by reasonable name of the existing
code, that sends and receives FDs via compel RPC socket.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 Makefile.compel                          |  2 +-
 compel/plugins/Makefile                  |  5 +++++
 compel/plugins/fds/fds.c                 | 25 +++++++++++++++++++++++++
 compel/plugins/include/uapi/plugin-fds.h |  7 +++++++
 4 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 compel/plugins/fds/fds.c
 create mode 100644 compel/plugins/include/uapi/plugin-fds.h

diff --git a/Makefile.compel b/Makefile.compel
index 408f0a7..3e7922e 100644
--- a/Makefile.compel
+++ b/Makefile.compel
@@ -22,7 +22,7 @@ compel-deps		+= compel/include/asm
 compel-deps		+= $(COMPEL_VERSION_HEADER)
 compel-deps		+= $(CONFIG_HEADER)
 compel-deps		+= include/common/asm
-compel-plugins		+= compel/plugins/std.built-in.o
+compel-plugins		+= compel/plugins/std.built-in.o compel/plugins/fds.built-in.o
 
 LIBCOMPEL_SO		:= libcompel.so
 LIBCOMPEL_A		:= libcompel.a
diff --git a/compel/plugins/Makefile b/compel/plugins/Makefile
index 0305c89..9f95fdc 100644
--- a/compel/plugins/Makefile
+++ b/compel/plugins/Makefile
@@ -50,6 +50,11 @@ std-obj-y		+= std/string.o
 std-obj-y		+= std/infect.o
 std-obj-y		+= ./$(PLUGIN_ARCH_DIR)/std/parasite-head.o
 
+#
+# FDS plugin
+target			+= fds
+fds-obj-y		+= fds/fds.o
+
 ifeq ($(SRCARCH),x86)
 	std-obj-y	+= ./$(PLUGIN_ARCH_DIR)/std/memcpy.o
 endif
diff --git a/compel/plugins/fds/fds.c b/compel/plugins/fds/fds.c
new file mode 100644
index 0000000..ffc058b
--- /dev/null
+++ b/compel/plugins/fds/fds.c
@@ -0,0 +1,25 @@
+#include <errno.h>
+
+#include "uapi/plugins.h"
+#include "uapi/plugin-std.h"
+#include <compel/plugins/std/infect.h>
+
+#define pr_err(fmt, ...)
+
+#include "common/compiler.h"
+#include "common/bug.h"
+
+#define __sys(foo)	sys_##foo
+#define __sys_err(ret)	ret
+
+#include "common/scm.h"
+
+int fds_send_fd(int fd)
+{
+	return send_fd(parasite_get_rpc_sock(), NULL, 0, fd);
+}
+
+int fds_recv_fd(void)
+{
+	return recv_fd(parasite_get_rpc_sock());
+}
diff --git a/compel/plugins/include/uapi/plugin-fds.h b/compel/plugins/include/uapi/plugin-fds.h
new file mode 100644
index 0000000..cececb2
--- /dev/null
+++ b/compel/plugins/include/uapi/plugin-fds.h
@@ -0,0 +1,7 @@
+#ifndef COMPEL_PLUGIN_STD_STD_H__
+#define COMPEL_PLUGIN_STD_STD_H__
+
+extern int fds_send_fd(int fd);
+extern int fds_recv_fd(void);
+
+#endif /* COMPEL_PLUGIN_STD_STD_H__ */
-- 
2.5.5



More information about the CRIU mailing list