mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
service: use setproctitle
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com> Acked-by: Kir Kolyshkin <kir@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
5e58a5dc9f
commit
9089ce89c4
2 changed files with 25 additions and 1 deletions
20
cr-service.c
20
cr-service.c
|
|
@ -26,6 +26,8 @@
|
|||
#include "mount.h"
|
||||
#include "cgroup.h"
|
||||
|
||||
#include "setproctitle.h"
|
||||
|
||||
unsigned int service_sk_ino = -1;
|
||||
|
||||
static int recv_criu_msg(int socket_fd, CriuReq **msg)
|
||||
|
|
@ -165,6 +167,8 @@ int send_criu_rpc_script(char *script, int fd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char images_dir[PATH_MAX];
|
||||
|
||||
static int setup_opts_from_req(int sk, CriuOpts *req)
|
||||
{
|
||||
struct ucred ids;
|
||||
|
|
@ -201,6 +205,12 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* get full path to images_dir to use in process title */
|
||||
if (readlink(images_dir_path, images_dir, PATH_MAX) == -1) {
|
||||
pr_perror("Can't readlink %s", images_dir_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* chdir to work dir */
|
||||
if (req->has_work_dir_fd)
|
||||
sprintf(work_dir_path, "/proc/%d/fd/%d", ids.pid, req->work_dir_fd);
|
||||
|
|
@ -325,6 +335,8 @@ static int dump_using_req(int sk, CriuOpts *req)
|
|||
if (setup_opts_from_req(sk, req))
|
||||
goto exit;
|
||||
|
||||
setproctitle("dump --rpc -t %d -D %s", req->pid, images_dir);
|
||||
|
||||
/*
|
||||
* FIXME -- cr_dump_tasks() may return code from custom
|
||||
* scripts, that can be positive. However, right now we
|
||||
|
|
@ -361,6 +373,8 @@ static int restore_using_req(int sk, CriuOpts *req)
|
|||
if (setup_opts_from_req(sk, req))
|
||||
goto exit;
|
||||
|
||||
setproctitle("restore --rpc -D %s", images_dir);
|
||||
|
||||
if (cr_restore_tasks())
|
||||
goto exit;
|
||||
|
||||
|
|
@ -398,6 +412,8 @@ static int check(int sk)
|
|||
|
||||
resp.type = CRIU_REQ_TYPE__CHECK;
|
||||
|
||||
setproctitle("check --rpc");
|
||||
|
||||
/* Check only minimal kernel support */
|
||||
opts.check_ms_kernel = true;
|
||||
|
||||
|
|
@ -424,6 +440,8 @@ static int pre_dump_using_req(int sk, CriuOpts *req)
|
|||
if (setup_opts_from_req(sk, req))
|
||||
goto cout;
|
||||
|
||||
setproctitle("pre-dump --rpc -t %d -D %s", req->pid, images_dir);
|
||||
|
||||
if (cr_pre_dump_tasks(req->pid))
|
||||
goto cout;
|
||||
|
||||
|
|
@ -487,6 +505,8 @@ static int start_page_server_req(int sk, CriuOpts *req)
|
|||
if (setup_opts_from_req(sk, req))
|
||||
goto out;
|
||||
|
||||
setproctitle("page-server --rpc --address %s --port %hu", opts.addr, opts.ps_port);
|
||||
|
||||
pr_debug("Starting page server\n");
|
||||
|
||||
ret = cr_page_server(true);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@
|
|||
#include "mount.h"
|
||||
#include "cgroup.h"
|
||||
|
||||
#include "setproctitle.h"
|
||||
|
||||
struct cr_options opts;
|
||||
|
||||
void init_opts(void)
|
||||
|
|
@ -119,7 +121,7 @@ Esyntax:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
pid_t pid = 0, tree_id = 0;
|
||||
int ret = -1;
|
||||
|
|
@ -181,6 +183,8 @@ int main(int argc, char *argv[])
|
|||
if (restrict_uid(getuid(), getgid()))
|
||||
return 1;
|
||||
|
||||
setproctitle_init(argc, argv, envp);
|
||||
|
||||
if (argc < 2)
|
||||
goto usage;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue