Skip to content

Add a plugin

To implement a vAccel plugin, all we need to do is add the implementation of the relevant frontend function and register it to the vAccel plugin subsystem.

To better understand the steps, it would be useful to go through lab1.

Get the code

First, lets grab the code:

git clone --recursive
cd vaccelrt

Clone the noop plugin

We will use the noop plugin as a skeleton for our new plugin which we will call helloworld. For simplicity, we copy the noop plugin directory structure to a new directory:

cp -avf plugins/noop plugins/helloworld

we replace noop with the name of our choosing (helloworld) so we come up with the following directory structure:

$ tree -L 1 plugins/helloworld
├── CMakeLists.txt
└── vaccel.c

We need to change the contents of plugins/helloworld/CMakeLists.txt to reflect the noop to helloworld change:

set(include_dirs ${CMAKE_SOURCE_DIR}/src)
set(SOURCES vaccel.c ${include_dirs}/vaccel.h ${include_dirs}/plugin.h)

add_library(vaccel-helloworld SHARED ${SOURCES})
target_include_directories(vaccel-helloworld PRIVATE ${include_dirs})

# Setup make install
install(TARGETS vaccel-helloworld DESTINATION "${lib_path}")

Similarly, we replace the plugin implementation with our own in vaccel.c, adding a simple message:

#include <stdio.h>
#include <plugin.h>

static int helloworld(struct vaccel_session *session)
    fprintf(stdout, "Calling vaccel-helloworld for session %u\n", session->session_id);

    printf("This is the helloworld plugin, implementing the NOOP operation!\n");

    return VACCEL_OK;

struct vaccel_op op = VACCEL_OP_INIT(op, VACCEL_NO_OP, helloworld);

static int init(void)
    return register_plugin_function(&op);

static int fini(void)
    return VACCEL_OK;

    .name = "helloworld",
    .version = "0.1",
    .init = init,
    .fini = fini

Additionally, we need to add the relevant rules in the CMakeLists.txt files to build the plugin along with the rest of the vAccelRT code.

We add the following to plugins/CMakeLists.txt:


and to CMakeLists.txt:

option(BUILD_PLUGIN_HELLOWORLD "Build the hello-world debugging plugin" OFF)

Now we can build our new plugin, by specifying the new option we just added:

Build our helloworld plugin

cd build

Use our helloworld plugin

We see that a new plugin is now available, Lets use this one instead of the noop one!

$ LD_LIBRARY_PATH=src VACCEL_DEBUG_LEVEL=4 VACCEL_BACKENDS=./plugins/helloworld/ ./hello_world
2021.04.09-12:40:45.86 - <debug> Initializing vAccel
2021.04.09-12:40:45.86 - <debug> Registered plugin helloworld
2021.04.09-12:40:45.86 - <debug> Registered function noop from plugin helloworld
2021.04.09-12:40:45.86 - <debug> Loaded plugin helloworld from ./plugins/helloworld/
2021.04.09-12:40:45.86 - <debug> session:1 New session
Initialized session with id: 1
2021.04.09-12:40:45.86 - <debug> session:1 Looking for plugin implementing noop
2021.04.09-12:40:45.86 - <debug> Found implementation in helloworld plugin
Calling vaccel-helloworld for session 1

This is the helloworld plugin, implementing the NOOP operation!

2021.04.09-12:40:45.86 - <debug> session:1 Free session
2021.04.09-12:40:45.86 - <debug> Shutting down vAccel
2021.04.09-12:40:45.86 - <debug> Cleaning up plugins
2021.04.09-12:40:45.86 - <debug> Unregistered plugin helloworld


We made it! We just added our own plugin to implement a vAccel operation: - we integrated it into the vAccel source tree, - we built it and - used it to run the noop operation.