Commit cd1a6dc9 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

cpuinfo: rpc -- Add CPUINFO_DUMP/CPUINFO_CHECK commands, v2

On Tue, Sep 30, 2014 at 09:18:55PM +0400, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>

Updated

>From fea15362291a525f4b00f7e070968c6890cc831e Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov@openvz.org>
Date: Fri, 19 Sep 2014 17:56:11 +0400
Subject: [PATCH 12/12] cpuinfo: rpc -- Add CPUINFO_DUMP/CPUINFO_CHECK commands
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 73b9a2eb
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "cr_options.h" #include "cr_options.h"
#include "util.h" #include "util.h"
#include "log.h" #include "log.h"
#include "cpu.h"
#include "pstree.h" #include "pstree.h"
#include "cr-service.h" #include "cr-service.h"
#include "cr-service-const.h" #include "cr-service-const.h"
...@@ -600,10 +601,56 @@ static int chk_keepopen_req(CriuReq *msg) ...@@ -600,10 +601,56 @@ static int chk_keepopen_req(CriuReq *msg)
if (msg->type == CRIU_REQ_TYPE__PAGE_SERVER) if (msg->type == CRIU_REQ_TYPE__PAGE_SERVER)
/* This just fork()-s so no leaks */ /* This just fork()-s so no leaks */
return 0; return 0;
else if (msg->type == CRIU_REQ_TYPE__CPUINFO_DUMP ||
msg->type == CRIU_REQ_TYPE__CPUINFO_CHECK)
return 0;
return -1; return -1;
} }
static int handle_cpuinfo(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("cpuinfo %s --rpc -D %s",
msg->type == CRIU_REQ_TYPE__CPUINFO_DUMP ?
"dump" : "check",
images_dir);
if (msg->type == CRIU_REQ_TYPE__CPUINFO_DUMP)
ret = cpuinfo_dump();
else
ret = cpuinfo_check();
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);
}
int cr_service_work(int sk) int cr_service_work(int sk)
{ {
int ret = -1; int ret = -1;
...@@ -634,6 +681,10 @@ more: ...@@ -634,6 +681,10 @@ more:
case CRIU_REQ_TYPE__PAGE_SERVER: case CRIU_REQ_TYPE__PAGE_SERVER:
ret = start_page_server_req(sk, msg->opts); ret = start_page_server_req(sk, msg->opts);
break; break;
case CRIU_REQ_TYPE__CPUINFO_DUMP:
case CRIU_REQ_TYPE__CPUINFO_CHECK:
ret = handle_cpuinfo(sk, msg);
break;
default: default:
send_criu_err(sk, "Invalid req"); send_criu_err(sk, "Invalid req");
......
...@@ -79,6 +79,9 @@ enum criu_req_type { ...@@ -79,6 +79,9 @@ enum criu_req_type {
PAGE_SERVER = 5; PAGE_SERVER = 5;
NOTIFY = 6; NOTIFY = 6;
CPUINFO_DUMP = 7;
CPUINFO_CHECK = 8;
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment