mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
cr-service: add pidfd_store_sk option to rpc.proto
pidfd_store_sk option will be used later to store tasks pidfds between predumps to detect pid reuse reliably. pidfd_store_sk should be a fd of a connectionless unix socket. init_pidfd_store_sk() steals the socket from the RPC client using pidfd_getfd, checks that it is a connectionless unix socket and checks if it is not initialized before (i.e. unnamed socket). If not initialized the socket is first bound to an abstract name (combination of the real pid/fd to avoid overlap), then it is connected to itself hence allowing us to store the pidfds in the receive queue of the socket (this is similar to how fdstore_init() works). v2: - avoid close(pidfd) overriding errno of SYS_pidfd_open in init_pidfd_store_sk() - close pidfd_store_sk because we might have leftover from previous iterations Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
This commit is contained in:
parent
a9508c9864
commit
e3c9c3429a
6 changed files with 117 additions and 0 deletions
11
lib/c/criu.c
11
lib/c/criu.c
|
|
@ -1782,3 +1782,14 @@ int criu_get_orphan_pts_master_fd(void)
|
|||
{
|
||||
return orphan_pts_master_fd;
|
||||
}
|
||||
|
||||
void criu_local_set_pidfd_store_sk(criu_opts *opts, int sk)
|
||||
{
|
||||
opts->rpc->has_pidfd_store_sk = true;
|
||||
opts->rpc->pidfd_store_sk = sk;
|
||||
}
|
||||
|
||||
void criu_set_pidfd_store_sk(int sk)
|
||||
{
|
||||
criu_local_set_pidfd_store_sk(global_opts, sk);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ int criu_add_inherit_fd(int fd, const char *key);
|
|||
int criu_add_external(const char *key);
|
||||
int criu_set_page_server_address_port(const char *address, int port);
|
||||
int criu_set_pre_dump_mode(enum criu_pre_dump_mode mode);
|
||||
void criu_set_pidfd_store_sk(int sk);
|
||||
|
||||
/*
|
||||
* The criu_notify_arg_t na argument is an opaque
|
||||
|
|
@ -260,6 +261,7 @@ int criu_local_add_inherit_fd(criu_opts *opts, int fd, const char *key);
|
|||
int criu_local_add_external(criu_opts *opts, const char *key);
|
||||
int criu_local_set_page_server_address_port(criu_opts *opts, const char *address, int port);
|
||||
int criu_local_set_pre_dump_mode(criu_opts *opts, enum criu_pre_dump_mode mode);
|
||||
void criu_local_set_pidfd_store_sk(criu_opts *opts, int sk);
|
||||
|
||||
void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue