[CRIU] [PATCH 2/2]v2 service: add support for check request

Ruslan Kuprieiev kupruser at gmail.com
Mon Nov 18 06:25:06 PST 2013


Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 cr-service.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/cr-service.c b/cr-service.c
index 65710fd..c337fce 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -217,6 +217,41 @@ exit:
 	return success ? 0 : 1;
 }
 
+/*
+ * Only checks criu ability to work in this enviroment.
+ */
+static int check_using_req(int sk, CriuOpts *req)
+{
+	bool success = false;
+	CriuResp msg = CRIU_RESP__INIT;
+	CriuCheckResp resp = CRIU_CHECK_RESP__INIT;
+
+	if (setup_opts_from_req(sk, req) == -1) {
+		pr_perror("Arguments treating fail");
+		goto exit;
+	}
+
+	if (cr_check() < 0) {
+		pr_perror("The kernel support isn't up-to-date");
+		goto exit;
+	}
+
+	resp.kernel = true;
+
+	success = true;
+exit:
+	msg.type = CRIU_REQ_TYPE__CHECK;
+	msg.success = success;
+	msg.check = &resp;
+
+	if (send_criu_msg(sk, &msg) == -1) {
+		pr_perror("Can't send response");
+		success = false;
+	}
+
+	return success ? 0 : 1;
+}
+
 static int cr_service_work(int sk)
 {
 	CriuReq *msg = 0;
@@ -233,6 +268,8 @@ static int cr_service_work(int sk)
 		return dump_using_req(sk, msg->opts);
 	case CRIU_REQ_TYPE__RESTORE:
 		return restore_using_req(sk, msg->opts);
+	case CRIU_REQ_TYPE__CHECK:
+		return check_using_req(sk, msg->opts);
 
 	default: {
 		CriuResp resp = CRIU_RESP__INIT;
-- 
1.8.1.2



More information about the CRIU mailing list