[CRIU] [PATCH 2/3] options: Add --ignore-queue option

Cyrill Gorcunov gorcunov at openvz.org
Wed Sep 3 11:06:16 PDT 2014


At the moment CRIU can't deal with queued data in fsnotify because
of lack of the kernel's API, iow if we see that there is a data
queued in fsnotify stack we refuse to proceed. But this might
be inconvenient for users so letf give them an option to ignore
queued data.

This option --ignore-queue is similar to --cpu-cap and supports
invertion by ^ prefix, like --ignore-queue ^inotify,fanotify

No real effect on CRIU behaviour yet, it'll be addressed later.
By default the @ignore_queues variable set to ignore all queues
in sake of backward compatibility.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 crtools.c            | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 include/cr_options.h |  9 +++++++++
 2 files changed, 56 insertions(+)

diff --git a/crtools.c b/crtools.c
index 130cd29b81d4..104f4e0b82a4 100644
--- a/crtools.c
+++ b/crtools.c
@@ -55,6 +55,7 @@ void init_opts(void)
 	opts.cpu_cap = CPU_CAP_ALL;
 	opts.manage_cgroups = false;
 	opts.ps_socket = -1;
+	opts.ignore_queues = IGNORE_QUEUE_ALL;
 }
 
 static int parse_ns_string(const char *ptr)
@@ -122,6 +123,47 @@ Esyntax:
 	return -1;
 }
 
+static int parse_ignore_queue(struct cr_options *opts, const char *optarg)
+{
+	bool inverse = false;
+
+#define ____set_cap(__opts, __cap, __inverse)			\
+	do {							\
+		if ((__inverse))				\
+			(__opts)->ignore_queues &= ~(__cap);	\
+		else						\
+			(__opts)->ignore_queues |=  (__cap);	\
+	} while (0)
+
+	for (; *optarg; optarg++) {
+		if (optarg[0] == '^') {
+			inverse = !inverse;
+			continue;
+		} else if (optarg[0] == ',') {
+			inverse = false;
+			continue;
+		}
+
+		if (!strncmp(optarg, "inotify", 7))
+			____set_cap(opts, IGNORE_QUEUE_INOTIFY, inverse);
+		else if (!strncmp(optarg, "fanotify", 8))
+			____set_cap(opts, IGNORE_QUEUE_FANOTIFY, inverse);
+		else if (!strncmp(optarg, "fsnotify", 8))
+			____set_cap(opts, IGNORE_QUEUE_FSNOTIFY, inverse);
+		else if (!strncmp(optarg, "all", 3))
+			____set_cap(opts, IGNORE_QUEUE_ALL, inverse);
+		else
+			goto Esyntax;
+	}
+#undef ____set_cap
+
+	return 0;
+
+Esyntax:
+	pr_err("Unknown ignoring queue mode `%s' selected\n", optarg);
+	return -1;
+}
+
 int main(int argc, char *argv[], char *envp[])
 {
 	pid_t pid = 0, tree_id = 0;
@@ -175,6 +217,7 @@ int main(int argc, char *argv[], char *envp[])
 		{ "exec-cmd", no_argument, 0, 1059},
 		{ "manage-cgroups", no_argument, 0, 1060},
 		{ "cgroup-root", required_argument, 0, 1061},
+		{ "ignore-queue", required_argument, 0, 1062},
 		{ },
 	};
 
@@ -384,6 +427,10 @@ int main(int argc, char *argv[], char *envp[])
 					return -1;
 			}
 			break;
+		case 1062:
+			if (parse_ignore_queue(&opts, optarg))
+				goto usage;
+			break;
 		case 'M':
 			{
 				char *aux;
diff --git a/include/cr_options.h b/include/cr_options.h
index b6038048b7b1..12e132583dcd 100644
--- a/include/cr_options.h
+++ b/include/cr_options.h
@@ -19,6 +19,14 @@ struct script {
 #define CPU_CAP_FPU		(1u)
 #define CPU_CAP_ALL		(-1u)
 
+/*
+ * Ignore queued data.
+ */
+#define IGNORE_QUEUE_ALL	(-1u)
+#define	IGNORE_QUEUE_INOTIFY	(1u)
+#define	IGNORE_QUEUE_FANOTIFY	(2u)
+#define IGNORE_QUEUE_FSNOTIFY	(IGNORE_QUEUE_INOTIFY | IGNORE_QUEUE_FANOTIFY)
+
 struct cg_root_opt {
 	struct list_head node;
 	char *controller;
@@ -61,6 +69,7 @@ struct cr_options {
 	bool			manage_cgroups;
 	char			*new_global_cg_root;
 	struct list_head	new_cgroup_roots;
+	unsigned int		ignore_queues;
 	bool			aufs;		/* auto-deteced, not via cli */
 };
 
-- 
1.9.3



More information about the CRIU mailing list