[CRIU] [PATCH 22/24] compel cli: add plugins cmd, use it

Kir Kolyshkin kir at openvz.org
Sat Dec 17 03:22:15 PST 2016


A compel user should not be aware of compel internals, including
the paths to various files. This commit introduces a command to
get the plugin files (well, currently just one plugin, "std").

Example for uninstalled compel:
 $ cd compel/test/infect/
 $ ../../../compel/compel-host plugins
 ../../../compel/plugins/std.built-in

Example for installed compel:
 $ compel plugins
 /usr/libexec/compel/std.built-in.o

The commit also makes use of this command by compel/test/infect
and criu/pie.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 compel/src/main.c           | 22 +++++++++++++++++++++-
 compel/test/infect/Makefile |  5 ++---
 criu/pie/Makefile           |  2 +-
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/compel/src/main.c b/compel/src/main.c
index c51d05b..42aa8e0 100644
--- a/compel/src/main.c
+++ b/compel/src/main.c
@@ -120,7 +120,7 @@ static int usage(int rc) {
 
 	fprintf(out,
 "Usage:\n"
-"  compel [--compat] includes | cflags | ldflags\n"
+"  compel [--compat] includes | cflags | ldflags | plugins\n"
 "  compel -f FILE -o FILE -p NAME [-l N] hgen\n"
 "    -f, --file FILE		input (parasite object) file name\n"
 "    -o, --output FILE		output (header) file name\n"
@@ -182,12 +182,25 @@ static void print_ldflags(bool compat)
 	}
 }
 
+static void print_plugins(const char *list[])
+{
+	while (*list != NULL) {
+		if (uninst_root)
+			printf("%s/plugins/%s.built-in.o\n",
+					uninst_root, *list);
+		else
+			printf("%s/compel/%s.built-in.o\n", LIBEXECDIR, *list);
+		list++;
+	}
+}
+
 int main(int argc, char *argv[])
 {
 	int log_level = DEFAULT_LOGLEVEL;
 	bool compat = false;
 	int opt, idx;
 	char *action;
+	const char *plugins_list[] = { "std", NULL };
 
 	static const char short_opts[] = "cf:o:p:hVl:";
 	static struct option long_opts[] = {
@@ -260,6 +273,13 @@ int main(int argc, char *argv[])
 		return 0;
 	}
 
+	if (!strcmp(action, "plugins")) {
+		// TODO: add option to specify additional plugins
+		// if/when we'll have any
+		print_plugins(plugins_list);
+		return 0;
+	}
+
 	if (!strcmp(action, "hgen")) {
 		if (!opts.input_filename) {
 			fprintf(stderr, "Error: option --file required\n");
diff --git a/compel/test/infect/Makefile b/compel/test/infect/Makefile
index 4ad8fd0..e9b96dd 100644
--- a/compel/test/infect/Makefile
+++ b/compel/test/infect/Makefile
@@ -2,7 +2,6 @@ CC	:= gcc
 CFLAGS	?= -O2 -g -Wall -Werror
 
 COMPEL		:= ../../../compel/compel-host
-COMPEL_PLUGINS	:= ../../../compel/plugins
 COMPEL_LIBRARY	:= ../../../compel/libcompel.a
 
 all: victim spy
@@ -25,8 +24,8 @@ parasite.h: parasite.po
 		-p parasite			\
 		-o $@
 
-parasite.po: parasite.o $(COMPEL_PLUGINS)/std.built-in.o
-	ld $(shell $(COMPEL) ldflags) -o $@ $^
+parasite.po: parasite.o
+	ld $(shell $(COMPEL) ldflags) -o $@ $^ $(shell $(COMPEL) plugins)
 
 parasite.o: parasite.c
 	$(CC) $(CFLAGS) -c $(shell $(COMPEL) cflags) -o $@ $^
diff --git a/criu/pie/Makefile b/criu/pie/Makefile
index 925729c..2083271 100644
--- a/criu/pie/Makefile
+++ b/criu/pie/Makefile
@@ -1,6 +1,5 @@
 target		+= parasite restorer
 
-compel_std	:= $(SRC_DIR)/compel/plugins/std.built-in.o
 parasite-obj-e	+= ./compel/plugins/std.built-in.o
 restorer-obj-e	+= ./compel/plugins/std.built-in.o
 
@@ -33,6 +32,7 @@ ccflags-y	+= -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
 
 ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
         CFLAGS	+= $(shell $(COMPEL_BIN) cflags)
+	compel_std	:= $(shell $(COMPEL_BIN) plugins)
 endif
 
 ifeq ($(SRCARCH),arm)
-- 
2.7.4



More information about the CRIU mailing list