Commit 2b5d0681 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

dump: pre-load kernel modules

See the comment below for an explanation of what is going on. We will
ultimately need to handle dumping the netlink data, but I think it is good to
prevent injecting events into the stream during a dump. So we pre-load the
modules, even though it isn't very pretty.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8764e745
...@@ -473,6 +473,8 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -473,6 +473,8 @@ int main(int argc, char *argv[], char *envp[])
pr_info("Will do snapshot from %s\n", opts.img_parent); pr_info("Will do snapshot from %s\n", opts.img_parent);
if (!strcmp(argv[optind], "dump")) { if (!strcmp(argv[optind], "dump")) {
preload_socket_modules();
if (!tree_id) if (!tree_id)
goto opt_pid_missing; goto opt_pid_missing;
return cr_dump_tasks(tree_id); return cr_dump_tasks(tree_id);
......
...@@ -28,6 +28,7 @@ extern int dump_socket_opts(int sk, SkOptsEntry *soe); ...@@ -28,6 +28,7 @@ extern int dump_socket_opts(int sk, SkOptsEntry *soe);
extern int restore_socket_opts(int sk, SkOptsEntry *soe); extern int restore_socket_opts(int sk, SkOptsEntry *soe);
extern void release_skopts(SkOptsEntry *); extern void release_skopts(SkOptsEntry *);
extern int restore_prepare_socket(int sk); extern int restore_prepare_socket(int sk);
extern void preload_socket_modules();
extern bool socket_test_collect_bit(unsigned int family, unsigned int proto); extern bool socket_test_collect_bit(unsigned int family, unsigned int proto);
......
...@@ -96,6 +96,41 @@ bool socket_test_collect_bit(unsigned int family, unsigned int proto) ...@@ -96,6 +96,41 @@ bool socket_test_collect_bit(unsigned int family, unsigned int proto)
return test_bit(nr, socket_cl_bits) != 0; return test_bit(nr, socket_cl_bits) != 0;
} }
void preload_socket_modules()
{
/*
* If the task to dump (e.g. an LXC container) has any netlink
* KOBJECT_UEVENT socket open and the _diag modules aren't
* loaded is dumped, criu will freeze the task and then the
* kernel will send it messages on the socket, and then we will
* fail to dump because the socket has pending data. The Real
* Solution is to dump this pending data, but we just modprobe
* things beforehand for now so that the first dump doesn't
* fail.
*
* We ignore failure since these could be compiled directly
* in, instead of being kernel modules.
*/
char *modules[] = {
"netlink_diag",
"af_packet_diag",
"udp_diag",
"tcp_diag",
"unix_diag",
NULL,
};
int i;
char *args[2] = {
"modprobe",
NULL
};
for (i = 0; modules[i]; i++) {
args[1] = modules[i];
cr_system(-1, -1, -1, args[0], args);
}
}
static int dump_bound_dev(int sk, SkOptsEntry *soe) static int dump_bound_dev(int sk, SkOptsEntry *soe)
{ {
int ret; int ret;
......
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