diff --git a/.criu.metadata b/.criu.metadata index 32249b0..b909fca 100644 --- a/.criu.metadata +++ b/.criu.metadata @@ -1 +1 @@ -511205e8fb4b170e70e3e97073c7d886d382b088 SOURCES/criu-1.6.1.tar.bz2 +975b007ef8824c5a266af58085fca4f9266cd28d SOURCES/criu-2.3.tar.bz2 diff --git a/.gitignore b/.gitignore index 9571d2a..054b213 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/criu-1.6.1.tar.bz2 +SOURCES/criu-2.3.tar.bz2 diff --git a/SOURCES/2fdef836a59938b169ca3c8f2c813b35258f1ed5.patch b/SOURCES/2fdef836a59938b169ca3c8f2c813b35258f1ed5.patch new file mode 100644 index 0000000..12abaa8 --- /dev/null +++ b/SOURCES/2fdef836a59938b169ca3c8f2c813b35258f1ed5.patch @@ -0,0 +1,115 @@ +From 2fdef836a59938b169ca3c8f2c813b35258f1ed5 Mon Sep 17 00:00:00 2001 +From: Adrian Reber +Date: Tue, 14 Jun 2016 10:13:00 +0300 +Subject: [PATCH] criu: add an option to skip in-flight connections + +Trying to migrate containers with tomcat and running ab as a test client +(ab -n 1000000 -c 20 http://url/to/test) criu sometimes exited with an +error if in-flight connections were detected. Criu can handle sockets +listening and with established connection. In-flight connections can +happen on sockets which do not yet have a full established connection +(SYN, SYN-ACK, and the last ACK is missing). + +This adds a new option to criu: + + --skip-in-flight this option skips in-flight TCP connections. + if TCP connections are found which are not yet completely + established, criu will ignore these connections in favor + of erroring out. + +With this option criu will skip sockets in this state and let's the client +handle the re-connection. + +Signed-off-by: Adrian Reber +Acked-by: Andrew Vagin +Signed-off-by: Pavel Emelyanov +--- + criu/crtools.c | 9 +++++++++ + criu/include/cr_options.h | 1 + + criu/include/sk-inet.h | 1 + + criu/sk-inet.c | 7 +++++++ + 4 files changed, 18 insertions(+) + +diff --git a/criu/crtools.c b/criu/crtools.c +index b527374..e7da5c7 100644 +--- a/criu/crtools.c ++++ b/criu/crtools.c +@@ -279,6 +279,7 @@ int main(int argc, char *argv[], char *envp[]) + { "extra", no_argument, 0, 1077 }, + { "experimental", no_argument, 0, 1078 }, + { "all", no_argument, 0, 1079 }, ++ { SK_INFLIGHT_PARAM, no_argument, 0, 1083 }, + { }, + }; + +@@ -583,6 +584,10 @@ int main(int argc, char *argv[], char *envp[]) + opts.check_extra_features = true; + opts.check_experimental_features = true; + break; ++ case 1083: ++ pr_msg("Will skip in-flight TCP connections\n"); ++ opts.tcp_skip_in_flight = true; ++ break; + case 'V': + pr_msg("Version: %s\n", CRIU_VERSION); + if (strcmp(CRIU_GITID, "0")) +@@ -791,6 +796,10 @@ int main(int argc, char *argv[], char *envp[]) + "* Special resources support:\n" + " -x|--" USK_EXT_PARAM "inode,.." " allow external unix connections (optionally can be assign socket's inode that allows one-sided dump)\n" + " --" SK_EST_PARAM " checkpoint/restore established TCP connections\n" ++" --" SK_INFLIGHT_PARAM " this option skips in-flight TCP connections.\n" ++" if TCP connections are found which are not yet completely\n" ++" established, criu will ignore these connections in favor\n" ++" of erroring out.\n" + " -r|--root PATH change the root filesystem (when run in mount namespace)\n" + " --evasive-devices use any path to a device file if the original one\n" + " is inaccessible\n" +diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h +index 32c9d4f..bf9feee 100644 +--- a/criu/include/cr_options.h ++++ b/criu/include/cr_options.h +@@ -109,6 +109,7 @@ struct cr_options { + char *lsm_profile; + unsigned int timeout; + unsigned int empty_ns; ++ bool tcp_skip_in_flight; + }; + + extern struct cr_options opts; +diff --git a/criu/include/sk-inet.h b/criu/include/sk-inet.h +index 4707a6e..9d2bda6 100644 +--- a/criu/include/sk-inet.h ++++ b/criu/include/sk-inet.h +@@ -72,6 +72,7 @@ extern int dump_one_tcp(int sk, struct inet_sk_desc *sd); + extern int restore_one_tcp(int sk, struct inet_sk_info *si); + + #define SK_EST_PARAM "tcp-established" ++#define SK_INFLIGHT_PARAM "skip-in-flight" + + extern int check_tcp(void); + extern mutex_t *inet_get_reuseaddr_lock(struct inet_sk_info *ii); +diff --git a/criu/sk-inet.c b/criu/sk-inet.c +index 20c6535..dfcfae6 100644 +--- a/criu/sk-inet.c ++++ b/criu/sk-inet.c +@@ -144,6 +144,11 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk) + switch (sk->state) { + case TCP_LISTEN: + if (sk->rqlen != 0) { ++ if (opts.tcp_skip_in_flight) { ++ pr_info("Skipping in-flight connection (l) for %x\n", ++ sk->sd.ino); ++ break; ++ } + /* + * Currently the ICONS nla reports the conn + * requests for listen sockets. Need to pick +@@ -151,6 +156,8 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk) + */ + pr_err("In-flight connection (l) for %x\n", + sk->sd.ino); ++ pr_err("In-flight connections can be ignored with the" ++ "--%s option.\n", SK_INFLIGHT_PARAM); + return 0; + } + break; diff --git a/SOURCES/98c8e44f749dd7ed0aa8c540f566bda54d7adfa1.patch b/SOURCES/98c8e44f749dd7ed0aa8c540f566bda54d7adfa1.patch deleted file mode 100644 index 2e976a1..0000000 --- a/SOURCES/98c8e44f749dd7ed0aa8c540f566bda54d7adfa1.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 98c8e44f749dd7ed0aa8c540f566bda54d7adfa1 Mon Sep 17 00:00:00 2001 -From: Andrey Vagin -Date: Thu, 2 Jul 2015 12:47:07 +0300 -Subject: [PATCH] pipe: don't create a tranport descriptor for inhereted pipes - -Otherwise we can get an error like this: -1: \t\tCreate transport fd /crtools-fd-1-5 -... -1: Found id pipe:[122747] (fd 8) in inherit fd list -1: File pipe:[122747] will be restored from fd 9 duped from inherit - -1: Error (util.c:131): fd 5 already in use (called at files.c:872) -Signed-off-by: Andrey Vagin -Signed-off-by: Pavel Emelyanov ---- - files.c | 3 +++ - pipes.c | 20 ++++++++++++-------- - 2 files changed, 15 insertions(+), 8 deletions(-) - -diff --git a/files.c b/files.c -index 4eeb988..3e69be7 100644 ---- a/files.c -+++ b/files.c -@@ -1394,6 +1394,9 @@ bool inherited_fd(struct file_desc *d, int *fd_p) - if (i_fd < 0) - return false; - -+ if (fd_p == NULL) -+ return true; -+ - *fd_p = dup(i_fd); - if (*fd_p < 0) - pr_perror("Inherit fd DUP failed"); -diff --git a/pipes.c b/pipes.c -index 7590472..62f550c 100644 ---- a/pipes.c -+++ b/pipes.c -@@ -393,18 +393,22 @@ static int collect_one_pipe(void *o, ProtobufCMessage *base) - pr_info("Collected pipe entry ID %#x PIPE ID %#x\n", - pi->pe->id, pi->pe->pipe_id); - -- list_for_each_entry(tmp, &pipes, list) -- if (pi->pe->pipe_id == tmp->pe->pipe_id) -- break; -+ if (file_desc_add(&pi->d, pi->pe->id, &pipe_desc_ops)) -+ return -1; - -- if (&tmp->list == &pipes) -- INIT_LIST_HEAD(&pi->pipe_list); -- else -- list_add(&pi->pipe_list, &tmp->pipe_list); -+ INIT_LIST_HEAD(&pi->pipe_list); -+ if (!inherited_fd(&pi->d, NULL)) { -+ list_for_each_entry(tmp, &pipes, list) -+ if (pi->pe->pipe_id == tmp->pe->pipe_id) -+ break; -+ -+ if (&tmp->list != &pipes) -+ list_add(&pi->pipe_list, &tmp->pipe_list); -+ } - - list_add_tail(&pi->list, &pipes); -- return file_desc_add(&pi->d, pi->pe->id, &pipe_desc_ops); - -+ return 0; - } - - struct collect_image_info pipe_cinfo = { diff --git a/SOURCES/aio-fix.patch b/SOURCES/aio-fix.patch index dbe63ed..8589d55 100644 --- a/SOURCES/aio-fix.patch +++ b/SOURCES/aio-fix.patch @@ -1,6 +1,6 @@ ---- a/aio.c 2015-07-01 11:02:50.360004543 -0400 -+++ b/aio.c 2015-07-01 11:03:33.099757812 -0400 -@@ -61,7 +61,7 @@ +--- a/criu/aio.c 2015-07-01 11:02:50.360004543 -0400 ++++ b/criu/aio.c 2015-07-01 11:03:33.099757812 -0400 +@@ -74,7 +74,7 @@ * up back to the k_max_reqs. */ diff --git a/SOURCES/criu-check-for-CLONE_NEWUSER-CLONE_NEWPID.patch b/SOURCES/criu-check-for-CLONE_NEWUSER-CLONE_NEWPID.patch deleted file mode 100644 index 736889d..0000000 --- a/SOURCES/criu-check-for-CLONE_NEWUSER-CLONE_NEWPID.patch +++ /dev/null @@ -1,65 +0,0 @@ -check: try to call clone with CLONE_NEWPID and CLONE_PARENT - -This combination was forbidden in 3.12 -commit 40a0d32d1eaffe6aac7324ca92604b6b3977eb0e : -"fork: unify and tighten up CLONE_NEWUSER/CLONE_NEWPID checks" - -and then it was permited again in 3.13: -commit 1f7f4dde5c945f41a7abc2285be43d918029ecc5 -fork: Allow CLONE_PARENT after setns(CLONE_NEWPID) - -Cc: Adrian Reber -Signed-off-by: Andrey Vagin ---- - cr-check.c | 28 ++++++++++++++++++++++++++++ - 1 file changed, 28 insertions(+) - -diff --git a/cr-check.c b/cr-check.c -index 7cf796a..bf1b729 100644 ---- a/cr-check.c -+++ b/cr-check.c -@@ -688,6 +688,33 @@ static int check_fdinfo_lock(void) - return 0; - } - -+struct clone_arg { -+ /* -+ * Reserve some space for clone() to locate arguments -+ * and retcode in this place -+ */ -+ char stack[128] __attribute__((aligned (8))); -+ char stack_ptr[0]; -+}; -+ -+static int clone_cb(void *_arg) { -+ exit(0); -+} -+ -+static int check_clone_parent_vs_pid() -+{ -+ struct clone_arg ca; -+ pid_t pid; -+ -+ pid = clone(clone_cb, ca.stack_ptr, CLONE_NEWPID | CLONE_PARENT, &ca); -+ if (pid < 0) { -+ pr_err("CLONE_PARENT | CLONE_NEWPID don't work together\n"); -+ return -1; -+ } -+ -+ return 0; -+} -+ - static int (*chk_feature)(void); - - int cr_check(void) -@@ -741,6 +768,7 @@ int cr_check(void) - ret |= check_mnt_id(); - ret |= check_aio_remap(); - ret |= check_fdinfo_lock(); -+ ret |= check_clone_parent_vs_pid(); - - out: - if (!ret) --- -2.1.0 - diff --git a/SOURCES/criu.8 b/SOURCES/criu.8 new file mode 100644 index 0000000..e621b62 --- /dev/null +++ b/SOURCES/criu.8 @@ -0,0 +1,883 @@ +'\" t +.\" Title: criu +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 06/14/2016 +.\" Manual: CRIU Manual +.\" Source: criu 2.3 +.\" Language: English +.\" +.TH "CRIU" "8" "06/14/2016" "criu 2\&.3" "CRIU Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +criu \- checkpoint/restore in userspace +.SH "SYNOPSIS" +.sp +\fBcriu\fR \fI\fR [\fIoptions\fR] +.SH "DESCRIPTION" +.sp +\fBcriu\fR is a tool for checkpointing and restoring running applications\&. It does this by saving their state as a collection of files (see the \fIdump\fR command) and creating equivalent processes from those files (see the \fIrestore\fR command)\&. The restore operation can be performed at a later time, on a different system, or both\&. +.SH "OPTIONS" +.sp +The options are depending on the \fI\fR \fBcriu\fR run with\&. +.SS "Common options" +.sp +Common options are applied to any \fI\fR\&. +.PP +\fB\-v\fR[\fI\fR|\fBv\fR\&...] +.RS 4 +Set logging level to +\fI\fR\&. The higer the level, the more output is produced\&. Either numeric values or multiple +\fBv\fR +can be used\&. + +The following levels are available: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fB\-v1\fR, +\fB\-v\fR +only messages and errors; +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fB\-v2\fR, +\fB\-vv\fR +also warnings (default level); +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fB\-v3\fR, +\fB\-vvv\fR +also information messages and timestamps; +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fB\-v4\fR, +\fB\-vvvv\fR +lots of debug\&. +.RE +.RE +.PP +\fB\-\-pidfile\fR \fI\fR +.RS 4 +Write root task, service or page\-server pid into a +\fI\fR\&. +.RE +.PP +\fB\-o\fR, \fB\-\-log\-file\fR \fI\fR +.RS 4 +Write logging messages to +\fI\fR\&. +.RE +.PP +\fB\-\-log\-pid\fR +.RS 4 +Write separate logging files per each pid\&. +.RE +.PP +\fB\-D\fR, \fB\-\-images\-dir\fR \fI\fR +.RS 4 +Use path +\fI\fR +as a base directory where to look for dump files set\&. +.RE +.PP +\fB\-\-prev\-images\-dir\fR \fI\fR +.RS 4 +Use path +\fI\fR +as a parent directory where to look for dump files set\&. This make sence in case of increment dumps\&. +.RE +.PP +\fB\-W\fR, \fB\-\-work\-dir\fR \fI\fR +.RS 4 +Use directory +\fI\fR +for putting logs, pidfiles and statistics\&. If not specified, +\fI\fR +from +\fB\-D\fR +option is taken\&. +.RE +.PP +\fB\-\-close\fR \fI\fR +.RS 4 +Close file with descriptor +\fI\fR +before any actions\&. +.RE +.PP +\fB\-L\fR, \fB\-\-libdir\fR \fI\fR +.RS 4 +Path to a plugins directory\&. +.RE +.PP +\fB\-\-action\-script\fR \fI