mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
cr-check: add ability to check if pidfd_store feature is supported
pidfd_store which will be used for reliable pidfd based pid reuse detection for RPC clients requires two recent syscalls (pidfd_open and pidfd_getfd). We allow checking if pidfd_store is supported using: 1. CLI: criu check --feature pidfd_store 2. RPC: CRIU_REQ_TYPE__FEATURE_CHECK and set pidfd_store to true in the "features" field of the request Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
This commit is contained in:
parent
e3c9c3429a
commit
ba882893c3
@ -1331,6 +1331,21 @@ static int check_net_diag_raw(void)
|
||||
socket_test_collect_bit(AF_INET6, IPPROTO_RAW)) ? 0 : -1;
|
||||
}
|
||||
|
||||
static int check_pidfd_store(void)
|
||||
{
|
||||
if (!kdat.has_pidfd_open) {
|
||||
pr_warn("Pidfd store requires pidfd_open syscall which is not supported\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!kdat.has_pidfd_getfd) {
|
||||
pr_warn("Pidfd store requires pidfd_getfd syscall which is not supported\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int (*chk_feature)(void);
|
||||
|
||||
/*
|
||||
@ -1443,6 +1458,7 @@ int cr_check(void)
|
||||
ret |= check_clone3_set_tid();
|
||||
ret |= check_time_namespace();
|
||||
ret |= check_newifindex();
|
||||
ret |= check_pidfd_store();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1551,6 +1567,7 @@ static struct feature_list feature_list[] = {
|
||||
{ "newifindex", check_newifindex},
|
||||
{ "nftables", check_nftables_cr },
|
||||
{ "has_ipt_legacy", check_ipt_legacy },
|
||||
{ "pidfd_store", check_pidfd_store },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
|
@ -1065,6 +1065,8 @@ static int handle_feature_check(int sk, CriuReq * msg)
|
||||
feat.mem_track = false;
|
||||
feat.has_lazy_pages = 1;
|
||||
feat.lazy_pages = false;
|
||||
feat.has_pidfd_store = 1;
|
||||
feat.pidfd_store = false;
|
||||
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
@ -1086,6 +1088,10 @@ static int handle_feature_check(int sk, CriuReq * msg)
|
||||
(msg->features->lazy_pages == true))
|
||||
feat.lazy_pages = kdat.has_uffd && uffd_noncooperative();
|
||||
|
||||
if ((msg->features->has_pidfd_store == 1) &&
|
||||
(msg->features->pidfd_store == true))
|
||||
feat.pidfd_store = kdat.has_pidfd_getfd && kdat.has_pidfd_open;
|
||||
|
||||
resp.features = &feat;
|
||||
resp.type = msg->type;
|
||||
/* The feature check is working, actual results are in resp.features */
|
||||
|
@ -174,6 +174,7 @@ enum criu_req_type {
|
||||
message criu_features {
|
||||
optional bool mem_track = 1;
|
||||
optional bool lazy_pages = 2;
|
||||
optional bool pidfd_store = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user