[CRIU] [PATCH 15/15] cpuinfo: rpc -- Add CPUINFO_DUMP/CPUINFO_CHECK commands

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


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-service.c       | 23 +++++++++++++++++++++++
 protobuf/rpc.proto |  3 +++
 2 files changed, 26 insertions(+)

diff --git a/cr-service.c b/cr-service.c
index d144f475570a..7c95e15a3804 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -17,6 +17,7 @@
 #include "cr_options.h"
 #include "util.h"
 #include "log.h"
+#include "cpu.h"
 #include "pstree.h"
 #include "cr-service.h"
 #include "cr-service-const.h"
@@ -582,6 +583,24 @@ static int chk_keepopen_req(CriuReq *msg)
 	return -1;
 }
 
+static int handle_cpuinfo(int sk, CriuReq *msg)
+{
+	CriuResp resp = CRIU_RESP__INIT;
+	bool success = false;
+
+	if (setup_opts_from_req(sk, msg->opts))
+		goto out;
+
+	if (msg->type == CRIU_REQ_TYPE__CPUINFO_DUMP)
+		success = cpu_dump_cpuinfo_single() ? false : true;
+	else
+		success = cpu_validate_image_cpuinfo_single() ? false : true;
+out:
+	resp.type = msg->type;
+	resp.success = success;
+	return send_criu_msg(sk, &resp);
+}
+
 int cr_service_work(int sk)
 {
 	int ret = -1;
@@ -612,6 +631,10 @@ more:
 	case CRIU_REQ_TYPE__PAGE_SERVER:
 		ret =  start_page_server_req(sk, msg->opts);
 		break;
+	case CRIU_REQ_TYPE__CPUINFO_DUMP:
+	case CRIU_REQ_TYPE__CPUINFO_CHECK:
+		ret = handle_cpuinfo(sk, msg);
+		break;
 
 	default:
 		send_criu_err(sk, "Invalid req");
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index 4617e7bc3ab1..d511512c5696 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -79,6 +79,9 @@ enum criu_req_type {
 	PAGE_SERVER	= 5;
 
 	NOTIFY		= 6;
+
+	CPUINFO_DUMP	= 7;
+	CPUINFO_CHECK	= 8;
 }
 
 /*
-- 
1.9.3



More information about the CRIU mailing list