[CRIU] [PATCH] dump: add timeout for dump
Andrey Ryabinin
aryabinin at virtuozzo.com
Fri Dec 4 04:26:03 PST 2015
Currently criu dump may hang indefinitely. E.g. in wait for task
that blocked in vfork(). This patch adds time limit on dump
operation. It's 20 seconds by default, but it could be changed via
parameter.
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
cr-dump.c | 2 ++
crtools.c | 10 ++++++++--
include/cr_options.h | 3 +++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index 5cc375d..04e1dd2 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1464,6 +1464,8 @@ int cr_dump_tasks(pid_t pid)
pr_info("Dumping processes (pid: %d)\n", pid);
pr_info("========================================\n");
+ alarm(opts.timeout);
+
pre_dump_ret = run_scripts(ACT_PRE_DUMP);
if (pre_dump_ret != 0) {
pr_err("Pre dump script failed with %d!\n", post_dump_ret);
diff --git a/crtools.c b/crtools.c
index d3812a1..17aac53 100644
--- a/crtools.c
+++ b/crtools.c
@@ -64,6 +64,7 @@ void init_opts(void)
opts.manage_cgroups = CG_MODE_DEFAULT;
opts.ps_socket = -1;
opts.ghost_limit = DEFAULT_GHOST_LIMIT;
+ opts.timeout = DEFAULT_TIMEOUT;
}
static int parse_ns_string(const char *ptr)
@@ -253,6 +254,7 @@ int main(int argc, char *argv[], char *envp[])
{ "freeze-cgroup", required_argument, 0, 1068 },
{ "ghost-limit", required_argument, 0, 1069 },
{ "irmap-scan-path", required_argument, 0, 1070 },
+ { "timeout", required_argument, 0, 1071 },
{ },
};
@@ -498,6 +500,9 @@ int main(int argc, char *argv[], char *envp[])
if (irmap_scan_path_add(optarg))
return -1;
break;
+ case 1071:
+ opts.timeout = atoi(optarg);
+ break;
case 'M':
{
char *aux;
@@ -708,8 +713,9 @@ usage:
" 'cpu','fpu','all','ins','none'. To disable capability, prefix it with '^'.\n"
" --exec-cmd execute the command specified after '--' on successful\n"
" restore making it the parent of the restored process\n"
-" --freeze-cgroup\n"
-" use cgroup freezer to collect processes\n"
+" --freeze-cgroup use cgroup freezer to collect processes\n"
+" --timeout seconds timeout in seconds for dump. Dumping will fail if timeout reached.\n"
+" If not specified timeout is 20 seconds\n"
"\n"
"* 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"
diff --git a/include/cr_options.h b/include/cr_options.h
index eac7283..6296721 100644
--- a/include/cr_options.h
+++ b/include/cr_options.h
@@ -38,6 +38,8 @@ struct cg_root_opt {
*/
#define DEFAULT_GHOST_LIMIT (1 << 20)
+#define DEFAULT_TIMEOUT 20
+
struct irmap;
struct irmap_path_opt {
@@ -95,6 +97,7 @@ struct cr_options {
bool overlayfs;
size_t ghost_limit;
struct list_head irmap_scan_paths;
+ unsigned int timeout;
};
extern struct cr_options opts;
--
2.4.10
More information about the CRIU
mailing list