2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

compel cli: add plugins cmd, use it

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.

travis-ci: success for More polishing for compel cli
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-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:
Kir Kolyshkin
2016-12-17 03:22:15 -08:00
committed by Andrei Vagin
parent 616c6d172a
commit 7ad7ee4d6c
3 changed files with 24 additions and 5 deletions

View File

@@ -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");

View File

@@ -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 $@ $^

View File

@@ -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
@@ -36,6 +35,7 @@ ccflags-y += -Wp,-U_FORTIFY_SOURCE -Wp,-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)