[CRIU] [PATCH] dump: pre-load kernel modules

Pavel Emelyanov xemul at parallels.com
Mon Oct 13 23:48:40 PDT 2014


On 10/13/2014 06:12 PM, Tycho Andersen wrote:
> 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.

Yeah, it looks like this is the only sane way of doing this.
Can we, btw, have this code located in sockets.c, as it's the
one who "knows" about the _diag subsys?

> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
>  crtools.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/crtools.c b/crtools.c
> index a245bbb..b663416 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -473,6 +473,38 @@ int main(int argc, char *argv[], char *envp[])
>  		pr_info("Will do snapshot from %s\n", opts.img_parent);
>  
>  	if (!strcmp(argv[optind], "dump")) {
> +		/*
> +		 * 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);
> +		}
> +
>  		if (!tree_id)
>  			goto opt_pid_missing;
>  		return cr_dump_tasks(tree_id);
> 



More information about the CRIU mailing list