[CRIU] [PATCH 02/12] opt: cpu-cap -- Introduce "none" and "cpuinfo" arguments

Cyrill Gorcunov gorcunov at openvz.org
Tue Sep 30 10:18:45 PDT 2014


They will serve to choose capability level when migrating
images between various hardware nodes.

Note it's bare functionality introduced in this commit,
the real implementation is in next patches.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 crtools.c            | 10 +++++++---
 include/cr_options.h |  5 ++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/crtools.c b/crtools.c
index b5f0a76ba866..87f442c72120 100644
--- a/crtools.c
+++ b/crtools.c
@@ -114,8 +114,12 @@ static int parse_cpu_cap(struct cr_options *opts, const char *optarg)
 
 		if (!strncmp(optarg, "fpu", 3))
 			____cpu_set_cap(opts, CPU_CAP_FPU, inverse);
-		if (!strncmp(optarg, "all", 3))
+		else if (!strncmp(optarg, "all", 3))
 			____cpu_set_cap(opts, CPU_CAP_ALL, inverse);
+		else if (!strncmp(optarg, "none", 3))
+			____cpu_set_cap(opts, CPU_CAP_NONE, inverse);
+		else if (!strncmp(optarg, "cpu", 3))
+			____cpu_set_cap(opts, CPU_CAP_CPU, inverse);
 		else
 			goto Esyntax;
 	}
@@ -561,8 +565,8 @@ usage:
 "     --pidfile FILE     write root task, service or page-server pid to FILE\n"
 "  -W|--work-dir DIR     directory to cd and write logs/pidfiles/stats to\n"
 "                        (if not specified, value of --images-dir is used)\n"
-"     --cpu-cap CAP      require certain cpu capability. CAP: may be one of:\n"
-"                        'fpu','all'. To disable capability, prefix it with '^'.\n"
+"     --cpu-cap [CAP]    require certain cpu capability. CAP: may be one of:\n"
+"                        'cpu','fpu','all','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"
 "\n"
diff --git a/include/cr_options.h b/include/cr_options.h
index 5a7edd9263db..a9f9e92259e6 100644
--- a/include/cr_options.h
+++ b/include/cr_options.h
@@ -8,8 +8,11 @@
 /*
  * CPU capability options.
  */
-#define CPU_CAP_FPU		(1u)
+#define CPU_CAP_NONE		(0u)
 #define CPU_CAP_ALL		(-1u)
+#define CPU_CAP_FPU		(1u)		/* Only FPU capability required */
+#define CPU_CAP_CPU		(2u)		/* CPU capability required */
+#define CPU_CAP_DEFAULT		(CPU_CAP_FPU)
 
 struct cg_root_opt {
 	struct list_head node;
-- 
1.9.3



More information about the CRIU mailing list