Commit a4525522 authored by Pavel Emelyanov's avatar Pavel Emelyanov

net: Add ability to dump external links with plugins

If we meet a link we cannot dump we call plugin to check
whether it's the link, that should be treated as external.

Note, that on restore we don't call any plugins, but
consider the setup-namespace script to move the respective
link into the namespace. Links are not hierarchical and
can be moved between namespaces easily, so it's OK to
delegate the link creation to the script.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6d683556
...@@ -35,6 +35,8 @@ typedef int (cr_plugin_restore_file_t)(int id); ...@@ -35,6 +35,8 @@ typedef int (cr_plugin_restore_file_t)(int id);
typedef int (cr_plugin_dump_ext_mount_t)(char *mountpoint, int id); typedef int (cr_plugin_dump_ext_mount_t)(char *mountpoint, int id);
typedef int (cr_plugin_restore_ext_mount_t)(int id, char *mountpoint, char *old_root, int *is_file); typedef int (cr_plugin_restore_ext_mount_t)(int id, char *mountpoint, char *old_root, int *is_file);
typedef int (cr_plugin_dump_ext_link_t)(int index, int type, char *kind);
/* Public API */ /* Public API */
extern int criu_get_image_dir(void); extern int criu_get_image_dir(void);
......
...@@ -17,4 +17,6 @@ int cr_plugin_restore_file(int id); ...@@ -17,4 +17,6 @@ int cr_plugin_restore_file(int id);
int cr_plugin_dump_ext_mount(char *mountpoint, int id); int cr_plugin_dump_ext_mount(char *mountpoint, int id);
int cr_plugin_restore_ext_mount(int id, char *mountpoint, char *old_root, int *is_file); int cr_plugin_restore_ext_mount(int id, char *mountpoint, char *old_root, int *is_file);
int cr_plugin_dump_ext_link(int index, int type, char *kind);
#endif #endif
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "sk-inet.h" #include "sk-inet.h"
#include "tun.h" #include "tun.h"
#include "util-pie.h" #include "util-pie.h"
#include "plugin.h"
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/netdev.pb-c.h" #include "protobuf/netdev.pb-c.h"
...@@ -103,8 +104,15 @@ static char *link_kind(struct ifinfomsg *ifi, struct rtattr **tb) ...@@ -103,8 +104,15 @@ static char *link_kind(struct ifinfomsg *ifi, struct rtattr **tb)
static int dump_unknown_device(struct ifinfomsg *ifi, char *kind, static int dump_unknown_device(struct ifinfomsg *ifi, char *kind,
struct rtattr **tb, struct cr_fdset *fds) struct rtattr **tb, struct cr_fdset *fds)
{ {
pr_err("Unsupported link %d (type %d kind %s)\n", int ret;
ifi->ifi_index, ifi->ifi_type, kind);
ret = cr_plugin_dump_ext_link(ifi->ifi_index, ifi->ifi_type, kind);
if (ret == 0)
return dump_one_netdev(ND_TYPE__EXTLINK, ifi, tb, fds, NULL);
if (ret == -ENOTSUP)
pr_err("Unsupported link %d (type %d kind %s)\n",
ifi->ifi_index, ifi->ifi_type, kind);
return -1; return -1;
} }
......
...@@ -21,6 +21,7 @@ struct cr_plugin_entry { ...@@ -21,6 +21,7 @@ struct cr_plugin_entry {
cr_plugin_restore_file_t *cr_plugin_restore_file; cr_plugin_restore_file_t *cr_plugin_restore_file;
cr_plugin_dump_ext_mount_t *cr_plugin_dump_ext_mount; cr_plugin_dump_ext_mount_t *cr_plugin_dump_ext_mount;
cr_plugin_restore_ext_mount_t *cr_plugin_restore_ext_mount; cr_plugin_restore_ext_mount_t *cr_plugin_restore_ext_mount;
cr_plugin_dump_ext_link_t *cr_plugin_dump_ext_link;
}; };
struct cr_plugin_entry *next; struct cr_plugin_entry *next;
...@@ -35,6 +36,7 @@ struct cr_plugins { ...@@ -35,6 +36,7 @@ struct cr_plugins {
struct cr_plugin_entry *cr_plugin_restore_file; struct cr_plugin_entry *cr_plugin_restore_file;
struct cr_plugin_entry *cr_plugin_dump_ext_mount; struct cr_plugin_entry *cr_plugin_dump_ext_mount;
struct cr_plugin_entry *cr_plugin_restore_ext_mount; struct cr_plugin_entry *cr_plugin_restore_ext_mount;
struct cr_plugin_entry *cr_plugin_dump_ext_link;
}; };
struct cr_plugins cr_plugins; struct cr_plugins cr_plugins;
...@@ -101,6 +103,11 @@ int cr_plugin_restore_ext_mount(int id, char *mountpoint, char *old_root, int *i ...@@ -101,6 +103,11 @@ int cr_plugin_restore_ext_mount(int id, char *mountpoint, char *old_root, int *i
return run_plugin_funcs(cr_plugin_restore_ext_mount, id, mountpoint, old_root, is_file); return run_plugin_funcs(cr_plugin_restore_ext_mount, id, mountpoint, old_root, is_file);
} }
int cr_plugin_dump_ext_link(int index, int type, char *kind)
{
return run_plugin_funcs(cr_plugin_dump_ext_link, index, type, kind);
}
static int cr_lib_load(char *path) static int cr_lib_load(char *path)
{ {
struct cr_plugin_entry *ce; struct cr_plugin_entry *ce;
...@@ -123,6 +130,8 @@ static int cr_lib_load(char *path) ...@@ -123,6 +130,8 @@ static int cr_lib_load(char *path)
add_plugin_func(cr_plugin_dump_ext_mount); add_plugin_func(cr_plugin_dump_ext_mount);
add_plugin_func(cr_plugin_restore_ext_mount); add_plugin_func(cr_plugin_restore_ext_mount);
add_plugin_func(cr_plugin_dump_ext_link);
ce = NULL; ce = NULL;
f_fini = dlsym(h, "cr_plugin_fini"); f_fini = dlsym(h, "cr_plugin_fini");
if (f_fini) { if (f_fini) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment