Commit 398705d4 authored by Ruslan Kuprieiev's avatar Ruslan Kuprieiev Committed by Pavel Emelyanov

rpc: rename criu_dump_req to criu_opts

Lets rename CriuDumpReq to CriuOpts, for the sake of readability and to
avoid coping code for restore mechanism, as CriuDumpReq and
CriuRestoreResp would have almost the same fields. Also, it would be
easier to introduce other types of requests.
Signed-off-by: 's avatarRuslan Kuprieiev <kurpuser@gmail.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4d80f502
...@@ -75,7 +75,7 @@ int send_criu_dump_resp(int socket_fd, bool success, bool restored) ...@@ -75,7 +75,7 @@ int send_criu_dump_resp(int socket_fd, bool success, bool restored)
return send_criu_msg(socket_fd, &msg); return send_criu_msg(socket_fd, &msg);
} }
static int setup_dump_from_req(int sk, CriuDumpReq *req) static int setup_dump_from_req(int sk, CriuOpts *req)
{ {
struct ucred ids; struct ucred ids;
struct stat st; struct stat st;
...@@ -149,7 +149,7 @@ static int setup_dump_from_req(int sk, CriuDumpReq *req) ...@@ -149,7 +149,7 @@ static int setup_dump_from_req(int sk, CriuDumpReq *req)
return 0; return 0;
} }
static int dump_using_req(int sk, CriuDumpReq *req) static int dump_using_req(int sk, CriuOpts *req)
{ {
bool success = false; bool success = false;
...@@ -186,7 +186,7 @@ static int cr_service_work(int sk) ...@@ -186,7 +186,7 @@ static int cr_service_work(int sk)
switch (msg->type) { switch (msg->type) {
case CRIU_REQ_TYPE__DUMP: case CRIU_REQ_TYPE__DUMP:
return dump_using_req(sk, msg->dump); return dump_using_req(sk, msg->opts);
default: { default: {
CriuResp resp = CRIU_RESP__INIT; CriuResp resp = CRIU_RESP__INIT;
......
message criu_dump_req { message criu_opts {
required int32 images_dir_fd = 1; required int32 images_dir_fd = 1;
optional int32 pid = 2; //if not set, will dump requesting process optional int32 pid = 2; //if not set on dump, will dump requesting process
optional bool leave_running = 3; optional bool leave_running = 3;
optional bool ext_unix_sk = 4; optional bool ext_unix_sk = 4;
...@@ -29,7 +29,7 @@ enum criu_req_type { ...@@ -29,7 +29,7 @@ enum criu_req_type {
message criu_req { message criu_req {
required criu_req_type type = 1; required criu_req_type type = 1;
optional criu_dump_req dump = 2; optional criu_opts opts = 2;
} }
/* /*
......
...@@ -83,24 +83,24 @@ int main() ...@@ -83,24 +83,24 @@ int main()
* Allocate CriuDumpReq. * Allocate CriuDumpReq.
*/ */
req.type = CRIU_REQ_TYPE__DUMP; req.type = CRIU_REQ_TYPE__DUMP;
req.dump = malloc(sizeof(CriuDumpReq)); req.opts = malloc(sizeof(CriuOpts));
if (!req.dump) { if (!req.opts) {
perror("Can't allocate memory for dump request"); perror("Can't allocate memory for dump request");
return -1; return -1;
} }
criu_dump_req__init(req.dump); criu_opts__init(req.opts);
/* /*
* Set dump options. * Set dump options.
* Checkout more in protobuf/rpc.proto. * Checkout more in protobuf/rpc.proto.
*/ */
req.dump->has_leave_running = true; req.opts->has_leave_running = true;
req.dump->leave_running = true; req.opts->leave_running = true;
req.dump->images_dir_fd = dir_fd; req.opts->images_dir_fd = dir_fd;
req.dump->has_shell_job = true; req.opts->has_shell_job = true;
req.dump->shell_job = true; req.opts->shell_job = true;
req.dump->log_level = 4; req.opts->log_level = 4;
/* /*
* Connect to service socket * Connect to service socket
......
...@@ -14,13 +14,13 @@ s.connect('criu_service.socket') ...@@ -14,13 +14,13 @@ s.connect('criu_service.socket')
# and set dump options. Checkout more options in protobuf/rpc.proto # and set dump options. Checkout more options in protobuf/rpc.proto
req = rpc.criu_req() req = rpc.criu_req()
req.type = rpc.DUMP req.type = rpc.DUMP
req.dump.leave_running = True req.opts.leave_running = True
req.dump.shell_job = True req.opts.shell_job = True
if not os.path.exists('imgs_py'): if not os.path.exists('imgs_py'):
os.makedirs('imgs_py') os.makedirs('imgs_py')
req.dump.images_dir_fd = os.open('imgs_py', os.O_DIRECTORY) req.opts.images_dir_fd = os.open('imgs_py', os.O_DIRECTORY)
# Send request # Send request
s.send(req.SerializeToString()) s.send(req.SerializeToString())
......
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