[CRIU] [PATCH] Query Dirty Tracking support via RPC
Adrian Reber
adrian at lisas.de
Mon Sep 28 07:17:54 PDT 2015
From: Adrian Reber <areber at redhat.com>
There are still systems which do not support dirty memory tracking.
This offers an interface to query the dirty memory tracking
availability via RPC. This is in preparation of a p.haul change
which will use this RPC interface to automatically detect if
pre-dumps should be executed or not.
Signed-off-by: Adrian Reber <areber at redhat.com>
---
cr-service.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
protobuf/rpc.proto | 2 ++
2 files changed, 49 insertions(+)
diff --git a/cr-service.c b/cr-service.c
index 938ea9e..53ea6e2 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -32,6 +32,7 @@
#include "security.h"
#include "sockets.h"
#include "irmap.h"
+#include "kerndat.h"
#include "setproctitle.h"
@@ -723,10 +724,53 @@ static int chk_keepopen_req(CriuReq *msg)
else if (msg->type == CRIU_REQ_TYPE__CPUINFO_DUMP ||
msg->type == CRIU_REQ_TYPE__CPUINFO_CHECK)
return 0;
+ else if (msg->type == CRIU_REQ_TYPE__DIRTY_TRACKING)
+ return 0;
return -1;
}
+static int handle_dirty_tracking(int sk, CriuReq *msg)
+{
+ CriuResp resp = CRIU_RESP__INIT;
+ bool success = false;
+ int pid, status;
+
+ pid = fork();
+ if (pid < 0) {
+ pr_perror("Can't fork");
+ goto out;
+ }
+
+ if (pid == 0) {
+ int ret = 1;
+
+ if (setup_opts_from_req(sk, msg->opts))
+ goto cout;
+
+ setproctitle("dirty-tracking --rpc -D %s",
+ images_dir);
+
+ kerndat_get_dirty_track();
+
+ if (kdat.has_dirty_track)
+ ret = 0;
+cout:
+ exit(ret);
+ }
+
+ wait(&status);
+ if (!WIFEXITED(status) || WEXITSTATUS(status))
+ goto out;
+
+ success = true;
+out:
+ resp.type = msg->type;
+ resp.success = success;
+
+ return send_criu_msg(sk, &resp);
+}
+
static int handle_cpuinfo(int sk, CriuReq *msg)
{
CriuResp resp = CRIU_RESP__INIT;
@@ -804,6 +848,9 @@ more:
case CRIU_REQ_TYPE__CPUINFO_CHECK:
ret = handle_cpuinfo(sk, msg);
break;
+ case CRIU_REQ_TYPE__DIRTY_TRACKING:
+ ret = handle_dirty_tracking(sk, msg);
+ break;
default:
send_criu_err(sk, "Invalid req");
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index 466780e..1f0e66e 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -115,6 +115,8 @@ enum criu_req_type {
CPUINFO_DUMP = 7;
CPUINFO_CHECK = 8;
+
+ DIRTY_TRACKING = 9;
}
/*
--
2.4.3
More information about the CRIU
mailing list