[CRIU] [PATCH 11/12] cpuinfo: Add "cpuinfo [dump|check]" commands

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


They allow to validate cpuinfo information
without running complete dump/restore actions.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 Documentation/criu.txt     |  7 +++++++
 arch/aarch64/cpu.c         | 11 +++++++++++
 arch/arm/cpu.c             | 11 +++++++++++
 arch/x86/cpu.c             | 25 +++++++++++++++++++++++++
 arch/x86/include/asm/cpu.h |  2 ++
 crtools.c                  |  2 ++
 include/cpu.h              |  2 ++
 7 files changed, 60 insertions(+)

diff --git a/Documentation/criu.txt b/Documentation/criu.txt
index d2feb17d0140..cf1a05d77119 100644
--- a/Documentation/criu.txt
+++ b/Documentation/criu.txt
@@ -50,6 +50,13 @@ Starts pagemap data deduplication procedure, where *criu* scans over all
 pagemap files and tries to minimalize the number of pagemap entries by
 obtaining the references from a parent pagemap image.
 
+*cpuinfo* *dump*::
+Writes information about currently running CPU and its features into an image.
+
+*cpuinfo* *check*::
+Reads information about CPU from an image file and checks if it is compatible
+with currently running CPU.
+
 OPTIONS
 -------
 *-c*::
diff --git a/arch/aarch64/cpu.c b/arch/aarch64/cpu.c
index 59f61b769c4c..f26608b46987 100644
--- a/arch/aarch64/cpu.c
+++ b/arch/aarch64/cpu.c
@@ -1,6 +1,7 @@
 #undef	LOG_PREFIX
 #define LOG_PREFIX "cpu: "
 
+#include <errno.h>
 #include "cpu.h"
 
 bool cpu_has_feature(unsigned int feature)
@@ -22,3 +23,13 @@ int cpu_validate_cpuinfo(void)
 {
 	return 0;
 }
+
+int cpu_dump_cpuinfo_single(void)
+{
+	return -ENOTSUP;
+}
+
+int cpu_validate_image_cpuinfo_single(void)
+{
+	return -ENOTSUP;
+}
diff --git a/arch/arm/cpu.c b/arch/arm/cpu.c
index 59f61b769c4c..f26608b46987 100644
--- a/arch/arm/cpu.c
+++ b/arch/arm/cpu.c
@@ -1,6 +1,7 @@
 #undef	LOG_PREFIX
 #define LOG_PREFIX "cpu: "
 
+#include <errno.h>
 #include "cpu.h"
 
 bool cpu_has_feature(unsigned int feature)
@@ -22,3 +23,13 @@ int cpu_validate_cpuinfo(void)
 {
 	return 0;
 }
+
+int cpu_dump_cpuinfo_single(void)
+{
+	return -ENOTSUP;
+}
+
+int cpu_validate_image_cpuinfo_single(void)
+{
+	return -ENOTSUP;
+}
diff --git a/arch/x86/cpu.c b/arch/x86/cpu.c
index fe2a96df4025..b90d428d53b6 100644
--- a/arch/x86/cpu.c
+++ b/arch/x86/cpu.c
@@ -358,3 +358,28 @@ err:
 	close(fd);
 	return ret;
 }
+
+int cpuinfo_dump(void)
+{
+	if (cpu_init())
+		return -1;
+	if (cpu_dump_cpuinfo())
+		return -1;
+	return 0;
+}
+
+int cpuinfo_check(void)
+{
+	if (cpu_init())
+		return -1;
+
+	/*
+	 * Force to check all caps because its been
+	 * called as a special command from options.
+	 */
+	opts.cpu_cap = CPU_CAP_ALL;
+
+	if (cpu_validate_cpuinfo())
+		return -1;
+	return 0;
+}
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index 8dcf9b4714c6..6f49229d6396 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -201,5 +201,7 @@ extern bool cpu_has_feature(unsigned int feature);
 extern int cpu_init(void);
 extern int cpu_dump_cpuinfo(void);
 extern int cpu_validate_cpuinfo(void);
+extern int cpuinfo_dump(void);
+extern int cpuinfo_check(void);
 
 #endif /* __CR_CPU_H__ */
diff --git a/crtools.c b/crtools.c
index 87f442c72120..d297abc59713 100644
--- a/crtools.c
+++ b/crtools.c
@@ -545,6 +545,8 @@ usage:
 "  page-server    launch page server\n"
 "  service        launch service\n"
 "  dedup          remove duplicates in memory dump\n"
+"  cpuinfo dump   writes cpu information into image file\n"
+"  cpuinfo check  validates cpu information read from image file\n"
 	);
 
 	if (usage_error) {
diff --git a/include/cpu.h b/include/cpu.h
index 152dc0a597ae..e94525a9e780 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -7,5 +7,7 @@ extern bool cpu_has_feature(unsigned int feature);
 extern int cpu_init(void);
 extern int cpu_dump_cpuinfo(void);
 extern int cpu_validate_cpuinfo(void);
+extern int cpuinfo_dump(void);
+extern int cpuinfo_check(void);
 
 #endif /* __CR_CPU_H__ */
-- 
1.9.3



More information about the CRIU mailing list