[CRIU] [PATCH 04/15] cpuinfo: x86 -- Add local copy of CpuinfoEntry

Cyrill Gorcunov gorcunov at openvz.org
Fri Sep 19 07:03:06 PDT 2014


We assume that all cpus in the system are same
family and stepping (it might be not true for
big systems but they are qute rare and not
guaranteed to work).

So we will use own local copy of protobuf entry
to fill it on startup and write into dump. On
restore we will need it to check caps with one
fetched from image file.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 arch/x86/cpu.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/arch/x86/cpu.c b/arch/x86/cpu.c
index e800bf3b62f2..2ea4e06bccc0 100644
--- a/arch/x86/cpu.c
+++ b/arch/x86/cpu.c
@@ -19,9 +19,16 @@
 
 #include "cpu.h"
 
+#include "protobuf.h"
+#include "protobuf/cpuinfo.pb-c.h"
+
 #undef	LOG_PREFIX
 #define LOG_PREFIX "cpu: "
 
+static CpuinfoEntry cpu_info = CPUINFO_ENTRY__INIT;
+static CpuinfoX86Entry cpu_x86_info = CPUINFO_X86_ENTRY__INIT;
+static CpuinfoX86Entry *cpu_x86_info_ptr = &cpu_x86_info;
+
 const char * const x86_cap_flags[NCAPINTS_BITS] = {
 	[X86_FEATURE_FPU]		= "fpu",
 	[X86_FEATURE_CX8]		= "cx8",
@@ -106,8 +113,22 @@ static int proc_cpuinfo_match(char *tok)
 	return 0;
 }
 
+#define protobuf_features_words (sizeof(cpu_features) / sizeof(cpu_x86_info.features[0]))
+
+static void cpu_init_protobuf(void)
+{
+	cpu_info.x86_entry = &cpu_x86_info_ptr;
+	cpu_info.n_x86_entry = 1;
+	cpu_info.id = 1;
+
+	cpu_x86_info.n_features = protobuf_features_words;
+	cpu_x86_info.features = (void *)cpu_features;
+}
+
 int cpu_init(void)
 {
+	cpu_init_protobuf();
+
 	if (parse_cpuinfo_features(proc_cpuinfo_match))
 		return -1;
 
-- 
1.9.3



More information about the CRIU mailing list