[CRIU] [PATCH 2/3] plugin: Rework plugins API

Cyrill Gorcunov gorcunov at openvz.org
Thu Mar 6 08:53:45 PST 2014


Here we define new api to be used in plugins.

 - Plugin should provide a descriptor with help of
   CR_PLUGIN_REGISTER macro, or in case if plugin require
   no init/exit functions -- with CR_PLUGIN_REGISTER_DUMMY.

 - Plugin should define a plugin hook with help of
   CR_PLUGIN_REGISTER_HOOK macro.

The idea behind is to not limit plugins authors with names
of functions they might need to use for particular hook.
Also plugin descriptor allows us to not call for additional
malloc()'s during plugin handling -- all information needed
will be stored in plugin descriptor statically allocated
in plugin library itself.

Such new API deprecates olds plugins structure but to keep
backward compatibility we will provide a tiny layer of
additional code to support old plugins for at least a couple
of release cycles.

For example a trivial plugin might look like

 | #include <sys/types.h>
 | #include <sys/stat.h>
 | #include <fcntl.h>
 | #include <libgen.h>
 | #include <errno.h>
 |
 | #include <sys/socket.h>
 | #include <linux/un.h>
 |
 | #include <stdio.h>
 | #include <stdlib.h>
 | #include <string.h>
 | #include <unistd.h>
 |
 | #include "criu-plugin.h"
 | #include "criu-log.h"
 |
 | static int dump_ext_file(int fd, int id)
 | {
 |	pr_info("dump_ext_file: fd %d id %d\n", fd, id);
 |	return 0;
 | }
 |
 | CR_PLUGIN_REGISTER_DUMMY("trivial")
 | CR_PLUGIN_REGISTER_HOOK(CR_PLUGIN_HOOK__DUMP_EXT_FILE, dump_ext_file)

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/criu-plugin.h | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/plugin.h      |  35 +++++++++++++++++
 2 files changed, 138 insertions(+)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-plugin-Rework-plugins-API.patch
Type: text/x-patch
Size: 5038 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/criu/attachments/20140306/8bc6899d/attachment-0001.bin>


More information about the CRIU mailing list