1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

added support for dynamically loaded plugins

This commit is contained in:
Steffen Vogel 2016-06-26 15:31:31 +02:00
parent 238c732feb
commit d811128459
3 changed files with 26 additions and 1 deletions

View file

@ -29,7 +29,7 @@ V ?= 2
GIT_REV=$(shell git rev-parse --short HEAD)
# Compiler and linker flags
LDLIBS = -pthread -lrt -lm -lconfig -lvillas
LDLIBS = -pthread -lrt -lm -lconfig -lvillas -ldl
LIB_LDFLAGS = -shared

View file

@ -95,6 +95,10 @@ fpga = {
)
}
plugins = [
"./lib/cbmodels/simple_circuit.so"
]
nodes = {
dma = {
datamover = "dma_0";

View file

@ -9,6 +9,7 @@
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <dlfcn.h>
#include "utils.h"
#include "list.h"
@ -83,6 +84,26 @@ int config_parse_global(config_setting_t *cfg, struct settings *set)
config_setting_lookup_int(cfg, "priority", &set->priority);
config_setting_lookup_int(cfg, "debug", &set->debug);
config_setting_lookup_float(cfg, "stats", &set->stats);
/* Load plugins */
cfg_plugins = config_setting_get_member(cfg, "plugins");
if (cfg) {
if (!config_setting_is_array(cfg_plugins))
cerror(cfg_plugins, "Setting 'plugings' must be a list of strings");
for (int i = 0; i < config_setting_length(cfg_plugins); i++) {
void *handle;
const char *path;
path = config_setting_get_string_elem(cfg_plugins, i);
if (!path)
cerror(cfg_plugins, "Setting 'plugings' must be a list of strings");
handle = dlopen(path, RTLD_NOW);
if (!handle)
error("Failed to load plugin %s", dlerror());
}
}
log_setlevel(set->debug, -1);