[CRIU] [PATCH v2 1/3] pid_ns: Extract functionality of exit of pid_ns helper in function
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Jul 14 15:40:15 MSK 2017
This functionality will be moved in criu task in next patches,
the patch is a preparation.
v2: Rename the function and move pr_err() to it.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/namespaces.h | 1 +
criu/namespaces.c | 33 ++++++++++++++++++++-------------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index 44520a81a..5dfa52295 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -278,6 +278,7 @@ static inline int pid_ns_root_off(void)
extern int reserve_pid_ns_helpers(void);
extern int create_pid_ns_helper(struct ns_id *ns);
extern int destroy_pid_ns_helpers(void);
+extern void warn_if_pid_ns_helper_exited(pid_t real_pid);
extern int request_set_next_pid(int pid_ns_id, pid_t pid, int sk);
#endif /* __CR_NS_H__ */
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 100a631e9..38235e6d7 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -1585,29 +1585,36 @@ static void unsc_msg_pid_fd(struct unsc_msg *um, pid_t *pid, int *fd)
}
}
+void warn_if_pid_ns_helper_exited(pid_t real_pid)
+{
+ struct ns_id *ns;
+ struct pid *pid;
+
+ for (ns = ns_ids; ns; ns = ns->next) {
+ if (ns->nd != &pid_ns_desc)
+ continue;
+ pid = __pstree_pid_by_virt(ns, ns->ns_pid);
+ if (pid->real == real_pid) {
+ pid->real = -1;
+ break;
+ }
+ }
+
+ if (ns)
+ pr_err("Spurious pid ns helper: pid=%d\n", real_pid);
+}
+
static void usernsd_handler(int signal, siginfo_t *siginfo, void *data)
{
pid_t pid = siginfo->si_pid;
- struct ns_id *ns;
- struct pid *tpid;
int status;
while (pid) {
pid = waitpid(-1, &status, WNOHANG);
if (pid <= 0)
return;
- for (ns = ns_ids; ns; ns = ns->next) {
- if (ns->nd != &pid_ns_desc)
- continue;
- tpid = __pstree_pid_by_virt(ns, ns->ns_pid);
- if (tpid->real == pid) {
- tpid->real = -1;
- break;
- }
- }
- if (!ns)
- pr_err("Spurious pid ns helper: pid=%d\n", pid);
+ warn_if_pid_ns_helper_exited(pid);
pr_err("%d finished unexpected: status=%d\n", pid, status);
futex_abort_and_wake(&task_entries->nr_in_progress);
More information about the CRIU
mailing list