Commit c487ad18 authored by Andrei Vagin's avatar Andrei Vagin

service: call cr_check() from a child process

cr_check() initializes root_item and calls collect_pstree_ids. It was
not designed to be called directly from a service process.
Signed-off-by: 's avatarAndrei Vagin <avagin@gmail.com>
parent 87c036be
...@@ -712,17 +712,36 @@ exit: ...@@ -712,17 +712,36 @@ exit:
return success ? 0 : 1; return success ? 0 : 1;
} }
static int check(int sk) static int check(int sk, CriuOpts *req)
{ {
int pid, status;
CriuResp resp = CRIU_RESP__INIT; CriuResp resp = CRIU_RESP__INIT;
resp.type = CRIU_REQ_TYPE__CHECK; resp.type = CRIU_REQ_TYPE__CHECK;
pid = fork();
if (pid < 0) {
pr_perror("Can't fork");
goto out;
}
if (pid == 0) {
setproctitle("check --rpc"); setproctitle("check --rpc");
if (!cr_check()) if (setup_opts_from_req(sk, req))
resp.success = true; exit(1);
exit(!!cr_check());
}
if (waitpid(pid, &status, 0) != pid) {
pr_perror("Unable to wait %d", pid);
goto out;
}
if (status)
goto out;
resp.success = true;
out:
return send_criu_msg(sk, &resp); return send_criu_msg(sk, &resp);
} }
...@@ -1122,7 +1141,7 @@ more: ...@@ -1122,7 +1141,7 @@ more:
ret = restore_using_req(sk, msg->opts); ret = restore_using_req(sk, msg->opts);
break; break;
case CRIU_REQ_TYPE__CHECK: case CRIU_REQ_TYPE__CHECK:
ret = check(sk); ret = check(sk, msg->opts);
break; break;
case CRIU_REQ_TYPE__PRE_DUMP: case CRIU_REQ_TYPE__PRE_DUMP:
ret = pre_dump_loop(sk, msg); ret = pre_dump_loop(sk, msg);
......
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