[CRIU] [PATCH 4/4] compel: add prefix to TASK_ defines

Kir Kolyshkin kir at openvz.org
Wed Feb 8 06:36:13 PST 2017


This patch adds COMPEL_ prefix to TASK_* defines used by compel
and criu, and also removes their duplicated definitions from
criu/include/pid.h

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 compel/include/uapi/infect.h | 24 +++++++++++++++---------
 compel/src/lib/infect.c      | 20 ++++++++++----------
 criu/cr-dump.c               | 26 +++++++++++++-------------
 criu/cr-restore.c            | 34 +++++++++++++++++-----------------
 criu/cr-service.c            |  2 +-
 criu/crtools.c               | 10 +++++-----
 criu/files-reg.c             |  8 ++++----
 criu/image.c                 |  2 +-
 criu/include/pid.h           | 10 +---------
 criu/include/pstree.h        |  3 ++-
 criu/proc_parse.c            |  2 +-
 criu/pstree.c                | 22 +++++++++++-----------
 criu/seccomp.c               |  2 +-
 criu/seize.c                 | 30 +++++++++++++++---------------
 criu/tty.c                   |  2 +-
 15 files changed, 98 insertions(+), 99 deletions(-)

diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h
index 5c47555..910e7a2 100644
--- a/compel/include/uapi/infect.h
+++ b/compel/include/uapi/infect.h
@@ -22,6 +22,21 @@ struct seize_task_status {
 	int			seccomp_mode;
 };
 
+/*
+ * Task state, as returned by compel_wait_task().
+ * Also used in other functions.
+ */
+enum
+{
+	COMPEL_TASK_UNDEF	= 0x0,
+	COMPEL_TASK_ALIVE	= 0x1,
+	COMPEL_TASK_DEAD	= 0x2,
+	COMPEL_TASK_STOPPED	= 0x3,
+	COMPEL_TASK_HELPER	= 0x4,
+	COMPEL_TASK_THREAD	= 0x5,
+	COMPEL_TASK_ZOMBIE	= 0x6,
+};
+
 extern int compel_wait_task(int pid, int ppid,
 		int (*get_status)(int pid, struct seize_task_status *),
 		struct seize_task_status *st);
@@ -29,15 +44,6 @@ extern int compel_wait_task(int pid, int ppid,
 extern int compel_stop_task(int pid);
 extern int compel_resume_task(pid_t pid, int orig_state, int state);
 
-/*
- * FIXME -- these should be mapped to pid.h's
- */
-
-#define TASK_ALIVE		0x1
-#define TASK_DEAD		0x2
-#define TASK_STOPPED		0x3
-#define TASK_ZOMBIE		0x6
-
 struct parasite_ctl;
 struct parasite_thread_ctl;
 
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index 8f36379..f6d4a44 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -235,9 +235,9 @@ try_again:
 		}
 
 		if (ret < 0)
-			return TASK_ZOMBIE;
+			return COMPEL_TASK_ZOMBIE;
 		else
-			return TASK_DEAD;
+			return COMPEL_TASK_DEAD;
 	}
 
 	if ((ppid != -1) && (ss->ppid != ppid)) {
@@ -289,11 +289,11 @@ try_again:
 		if (skip_sigstop(pid, nr_sigstop))
 			goto err_stop;
 
-		return TASK_STOPPED;
+		return COMPEL_TASK_STOPPED;
 	}
 
 	if (si.si_signo == SIGTRAP)
-		return TASK_ALIVE;
+		return COMPEL_TASK_ALIVE;
 	else {
 		pr_err("SEIZE %d: unsupported stop signal %d\n", pid, si.si_signo);
 		goto err;
@@ -311,25 +311,25 @@ int compel_resume_task(pid_t pid, int orig_st, int st)
 {
 	pr_debug("\tUnseizing %d into %d\n", pid, st);
 
-	if (st == TASK_DEAD) {
+	if (st == COMPEL_TASK_DEAD) {
 		kill(pid, SIGKILL);
 		return 0;
-	} else if (st == TASK_STOPPED) {
+	} else if (st == COMPEL_TASK_STOPPED) {
 		/*
 		 * Task might have had STOP in queue. We detected such
-		 * guy as TASK_STOPPED, but cleared signal to run the
-		 * parasite code. hus after detach the task will become
+		 * guy as COMPEL_TASK_STOPPED, but cleared signal to run
+		 * the parasite code. Thus after detach the task will be
 		 * running. That said -- STOP everyone regardless of
 		 * the initial state.
 		 */
 		kill(pid, SIGSTOP);
-	} else if (st == TASK_ALIVE) {
+	} else if (st == COMPEL_TASK_ALIVE) {
 		/*
 		 * Same as in the comment above -- there might be a
 		 * task with STOP in queue that would get lost after
 		 * detach, so stop it again.
 		 */
-		if (orig_st == TASK_STOPPED)
+		if (orig_st == COMPEL_TASK_STOPPED)
 			kill(pid, SIGSTOP);
 	} else
 		pr_err("Unknown final state %d\n", st);
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 8ccb5cb..b9e6ab6 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -642,7 +642,7 @@ int get_task_ids(struct pstree_item *item)
 
 	task_kobj_ids_entry__init(item->ids);
 
-	if (item->pid->state != TASK_DEAD) {
+	if (item->pid->state != COMPEL_TASK_DEAD) {
 		ret = dump_task_kobj_ids(item);
 		if (ret)
 			goto err_free;
@@ -784,14 +784,14 @@ static int collect_pstree_ids_predump(void)
 	 * write_img_inventory().
 	 */
 
-	crt.i.pid->state = TASK_ALIVE;
+	crt.i.pid->state = COMPEL_TASK_ALIVE;
 	crt.i.pid->real = getpid();
 
 	if (predump_task_ns_ids(&crt.i))
 		return -1;
 
 	for_each_pstree_item(item) {
-		if (item->pid->state == TASK_DEAD)
+		if (item->pid->state == COMPEL_TASK_DEAD)
 			continue;
 
 		if (predump_task_ns_ids(item))
@@ -861,7 +861,7 @@ static int dump_one_zombie(const struct pstree_item *item,
 		return -1;
 
 	strlcpy((char *)core->tc->comm, pps->comm, TASK_COMM_LEN);
-	core->tc->task_state = TASK_DEAD;
+	core->tc->task_state = COMPEL_TASK_DEAD;
 	core->tc->exit_code = pps->exit_code;
 
 	img = open_image(CR_FD_CORE, O_DUMP, item->pid->ns[0].virt);
@@ -1077,7 +1077,7 @@ static int dump_zombies(void)
 	 */
 
 	for_each_pstree_item(item) {
-		if (item->pid->state != TASK_DEAD)
+		if (item->pid->state != COMPEL_TASK_DEAD)
 			continue;
 
 		if (item->pid->ns[0].virt < 0) {
@@ -1126,12 +1126,12 @@ static int pre_dump_one_task(struct pstree_item *item)
 	pr_info("Pre-dumping task (pid: %d)\n", pid);
 	pr_info("========================================\n");
 
-	if (item->pid->state == TASK_STOPPED) {
+	if (item->pid->state == COMPEL_TASK_STOPPED) {
 		pr_warn("Stopped tasks are not supported\n");
 		return 0;
 	}
 
-	if (item->pid->state == TASK_DEAD)
+	if (item->pid->state == COMPEL_TASK_DEAD)
 		return 0;
 
 	ret = collect_mappings(pid, &vmas, NULL);
@@ -1206,7 +1206,7 @@ static int dump_one_task(struct pstree_item *item)
 	pr_info("Dumping task (pid: %d)\n", pid);
 	pr_info("========================================\n");
 
-	if (item->pid->state == TASK_DEAD)
+	if (item->pid->state == COMPEL_TASK_DEAD)
 		/*
 		 * zombies are dumped separately in dump_zombies()
 		 */
@@ -1446,7 +1446,7 @@ static int cr_pre_dump_finish(int ret)
 {
 	struct pstree_item *item;
 
-	pstree_switch_state(root_item, TASK_ALIVE);
+	pstree_switch_state(root_item, COMPEL_TASK_ALIVE);
 
 	timing_stop(TIME_FROZEN);
 
@@ -1520,9 +1520,9 @@ int cr_pre_dump_tasks(pid_t pid)
 		opts.track_mem = true;
 	}
 
-	if (opts.final_state == TASK_DEAD) {
+	if (opts.final_state == COMPEL_TASK_DEAD) {
 		pr_info("Enforcing tasks run after pre-dump.\n");
-		opts.final_state = TASK_ALIVE;
+		opts.final_state = COMPEL_TASK_ALIVE;
 	}
 
 	if (init_stats(DUMP_STATS))
@@ -1649,7 +1649,7 @@ static int cr_dump_finish(int ret)
 	 *    consistency of the FS and other resources, we simply
 	 *    start rollback procedure and cleanup everyhting.
 	 */
-	if (ret || post_dump_ret || opts.final_state == TASK_ALIVE) {
+	if (ret || post_dump_ret || opts.final_state == COMPEL_TASK_ALIVE) {
 		network_unlock();
 		delete_link_remaps();
 		clean_cr_time_mounts();
@@ -1660,7 +1660,7 @@ static int cr_dump_finish(int ret)
 
 	pstree_switch_state(root_item,
 			    (ret || post_dump_ret) ?
-			    TASK_ALIVE : opts.final_state);
+			    COMPEL_TASK_ALIVE : opts.final_state);
 	timing_stop(TIME_FROZEN);
 	free_pstree(root_item);
 	free_file_locks();
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 9acde67..3175690 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -245,7 +245,7 @@ static int root_prepare_shared(void)
 	}
 
 	for_each_pstree_item(pi) {
-		if (pi->pid->state == TASK_HELPER)
+		if (pi->pid->state == COMPEL_TASK_HELPER)
 			continue;
 
 		ret = prepare_mm_pid(pi);
@@ -523,8 +523,8 @@ static int collect_child_pids(int state, unsigned int *n)
 
 	if (current == root_item) {
 		for_each_pstree_item(pi) {
-			if (pi->pid->state != TASK_HELPER &&
-			    pi->pid->state != TASK_DEAD)
+			if (pi->pid->state != COMPEL_TASK_HELPER &&
+			    pi->pid->state != COMPEL_TASK_DEAD)
 				continue;
 			if (__collect_child_pids(pi, state, n))
 				return -1;
@@ -537,13 +537,13 @@ static int collect_child_pids(int state, unsigned int *n)
 static int collect_helper_pids(struct task_restore_args *ta)
 {
 	ta->helpers = (pid_t *)rst_mem_align_cpos(RM_PRIVATE);
-	return collect_child_pids(TASK_HELPER, &ta->helpers_n);
+	return collect_child_pids(COMPEL_TASK_HELPER, &ta->helpers_n);
 }
 
 static int collect_zombie_pids(struct task_restore_args *ta)
 {
 	ta->zombies = (pid_t *)rst_mem_align_cpos(RM_PRIVATE);
-	return collect_child_pids(TASK_DEAD, &ta->zombies_n);
+	return collect_child_pids(COMPEL_TASK_DEAD, &ta->zombies_n);
 }
 
 static int open_core(int pid, CoreEntry **pcore)
@@ -780,13 +780,13 @@ static int wait_on_helpers_zombies(void)
 		int status;
 
 		switch (pi->pid->state) {
-		case TASK_DEAD:
+		case COMPEL_TASK_DEAD:
 			if (waitid(P_PID, pid, NULL, WNOWAIT | WEXITED) < 0) {
 				pr_perror("Wait on %d zombie failed", pid);
 				return -1;
 			}
 			break;
-		case TASK_HELPER:
+		case COMPEL_TASK_HELPER:
 			if (waitpid(pid, &status, 0) != pid) {
 				pr_perror("waitpid for helper %d failed", pid);
 				return -1;
@@ -857,7 +857,7 @@ static int check_core(CoreEntry *core, struct pstree_item *me)
 		goto out;
 	}
 
-	if (core->tc->task_state != TASK_DEAD) {
+	if (core->tc->task_state != COMPEL_TASK_DEAD) {
 		if (!core->ids && !me->ids) {
 			pr_err("Core IDS data missed for non-zombie\n");
 			goto out;
@@ -882,9 +882,9 @@ static int restore_one_task(int pid, CoreEntry *core)
 
 	if (task_alive(current))
 		ret = restore_one_alive_task(pid, core);
-	else if (current->pid->state == TASK_DEAD)
+	else if (current->pid->state == COMPEL_TASK_DEAD)
 		ret = restore_one_zombie(core);
-	else if (current->pid->state == TASK_HELPER) {
+	else if (current->pid->state == COMPEL_TASK_HELPER) {
 		sigset_t blockmask, oldmask;
 
 		sigemptyset(&blockmask);
@@ -969,7 +969,7 @@ static inline int fork_with_pid(struct pstree_item *item)
 	int ret = -1;
 	pid_t pid = item->pid->ns[0].virt;
 
-	if (item->pid->state != TASK_HELPER) {
+	if (item->pid->state != COMPEL_TASK_HELPER) {
 		if (open_core(pid, &ca.core))
 			return -1;
 
@@ -981,7 +981,7 @@ static inline int fork_with_pid(struct pstree_item *item)
 
 		rsti(item)->has_seccomp = ca.core->tc->seccomp_mode != SECCOMP_MODE_DISABLED;
 
-		if (item->pid->state != TASK_DEAD && !task_alive(item)) {
+		if (item->pid->state != COMPEL_TASK_DEAD && !task_alive(item)) {
 			pr_err("Unknown task state %d\n", item->pid->state);
 			return -1;
 		}
@@ -1115,7 +1115,7 @@ static void sigchld_handler(int signal, siginfo_t *siginfo, void *data)
 				break;
 
 		BUG_ON(&pi->sibling == &current->children);
-		if (pi->pid->state != TASK_HELPER)
+		if (pi->pid->state != COMPEL_TASK_HELPER)
 			break;
 	}
 
@@ -1352,7 +1352,7 @@ static int restore_task_with_children(void *_arg)
 	if ( !(ca->clone_flags & CLONE_FILES))
 		close_safe(&ca->fd);
 
-	if (current->pid->state != TASK_HELPER) {
+	if (current->pid->state != COMPEL_TASK_HELPER) {
 		ret = clone_service_fd(rsti(current)->service_fd_id);
 		if (ret)
 			goto err;
@@ -1652,8 +1652,8 @@ static void finalize_restore(void)
 
 		xfree(ctl);
 
-		if ((item->pid->state == TASK_STOPPED) ||
-				(opts.final_state == TASK_STOPPED))
+		if ((item->pid->state == COMPEL_TASK_STOPPED) ||
+				(opts.final_state == COMPEL_TASK_STOPPED))
 			kill(item->pid->real, SIGSTOP);
 	}
 }
@@ -1881,7 +1881,7 @@ static int restore_root_task(struct pstree_item *init)
 
 	/* Zombies die after CR_STATE_RESTORE */
 	for_each_pstree_item(item) {
-		if (item->pid->state == TASK_DEAD)
+		if (item->pid->state == COMPEL_TASK_DEAD)
 			task_entries->nr_threads--;
 	}
 
diff --git a/criu/cr-service.c b/criu/cr-service.c
index 4bac50d..d53478b 100644
--- a/criu/cr-service.c
+++ b/criu/cr-service.c
@@ -294,7 +294,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 
 	/* checking flags from client */
 	if (req->has_leave_running && req->leave_running)
-		opts.final_state = TASK_ALIVE;
+		opts.final_state = COMPEL_TASK_ALIVE;
 
 	if (!req->has_pid) {
 		req->has_pid = true;
diff --git a/criu/crtools.c b/criu/crtools.c
index cce8073..d457f70 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -62,7 +62,7 @@ void init_opts(void)
 	memset(&opts, 0, sizeof(opts));
 
 	/* Default options */
-	opts.final_state = TASK_DEAD;
+	opts.final_state = COMPEL_TASK_DEAD;
 	INIT_LIST_HEAD(&opts.ext_mounts);
 	INIT_LIST_HEAD(&opts.inherit_fds);
 	INIT_LIST_HEAD(&opts.external);
@@ -331,10 +331,10 @@ int main(int argc, char *argv[], char *envp[])
 
 		switch (opt) {
 		case 's':
-			opts.final_state = TASK_STOPPED;
+			opts.final_state = COMPEL_TASK_STOPPED;
 			break;
 		case 'R':
-			opts.final_state = TASK_ALIVE;
+			opts.final_state = COMPEL_TASK_ALIVE;
 			break;
 		case 'x':
 			if (optarg && unix_sk_ids_parse(optarg) < 0)
@@ -607,7 +607,7 @@ int main(int argc, char *argv[], char *envp[])
 		case 1085:
 			pr_msg("Only checking if requested operation will succeed\n");
 			opts.check_only = true;
-			opts.final_state = TASK_ALIVE;
+			opts.final_state = COMPEL_TASK_ALIVE;
 			break;
 		case 1086:
 			opts.display_stats = true;
@@ -703,7 +703,7 @@ int main(int argc, char *argv[], char *envp[])
 	 */
 	if (!strcmp(argv[optind], "restore") &&
 			opts.restore_detach &&
-			opts.final_state == TASK_STOPPED &&
+			opts.final_state == COMPEL_TASK_STOPPED &&
 			opts.shell_job)
 		pr_warn("Stopped and detached shell job will get SIGHUP from OS.");
 
diff --git a/criu/files-reg.c b/criu/files-reg.c
index df270a6..308ab5c 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -383,7 +383,7 @@ static int open_remap_dead_process(struct reg_file_info *rfi,
 	if (!helper)
 		return -1;
 
-	if (helper->pid->state != TASK_UNDEF) {
+	if (helper->pid->state != COMPEL_TASK_UNDEF) {
 		pr_info("Skipping helper for restoring /proc/%d; pid exists\n", rfe->remap_id);
 		return 0;
 	}
@@ -816,7 +816,7 @@ int dead_pid_conflict(void)
 		if (!node)
 			continue;
 
-		if (node->state != TASK_THREAD) {
+		if (node->state != COMPEL_TASK_THREAD) {
 			struct pstree_item *item;
 
 			/*
@@ -955,8 +955,8 @@ static int check_path_remap(struct fd_link *link, const struct fd_parms *parms,
 	if (parms->fs_type == PROC_SUPER_MAGIC) {
 		/* The file points to /proc/pid/<foo> where pid is a dead
 		 * process. We remap this file by adding this pid to be
-		 * fork()ed into a TASK_HELPER state so that we can point to it
-		 * on restore.
+		 * fork()ed into a COMPEL_TASK_HELPER state so that we
+		 * can point to it on restore.
 		 */
 		pid_t pid;
 		char *start, *end;
diff --git a/criu/image.c b/criu/image.c
index 898a580..50ce6c7 100644
--- a/criu/image.c
+++ b/criu/image.c
@@ -133,7 +133,7 @@ int prepare_inventory(InventoryEntry *he)
 		he->check_only = true;
 	}
 
-	crt.i.pid->state = TASK_ALIVE;
+	crt.i.pid->state = COMPEL_TASK_ALIVE;
 	crt.i.pid->real = getpid();
 	if (get_task_ids(&crt.i))
 		return -1;
diff --git a/criu/include/pid.h b/criu/include/pid.h
index 9ac583f..4c0a47b 100644
--- a/criu/include/pid.h
+++ b/criu/include/pid.h
@@ -13,7 +13,7 @@ struct pid {
 	 */
 	pid_t real;
 
-	int state;	/* TASK_XXX constants */
+	int state;	/* COMPEL_TASK_XXX constants */
 
 	/*
 	 * The @virt pid is one which used in the image itself and keeps
@@ -26,14 +26,6 @@ struct pid {
 	} ns[1]; /* Must be at the end of struct pid */
 };
 
-#define TASK_UNDEF		0x0
-#define TASK_ALIVE		0x1
-#define TASK_DEAD		0x2
-#define TASK_STOPPED		0x3
-#define TASK_HELPER		0x4
-#define TASK_THREAD		0x5
-#define TASK_ZOMBIE		0x6
-
 /*
  * When we have to restore a shared resource, we mush select which
  * task should do it, and make other(s) wait for it. In order to
diff --git a/criu/include/pstree.h b/criu/include/pstree.h
index f441d53..06dfa39 100644
--- a/criu/include/pstree.h
+++ b/criu/include/pstree.h
@@ -5,6 +5,7 @@
 #include "common/lock.h"
 #include "pid.h"
 #include "images/core.pb-c.h"
+#include <compel/infect.h>
 
 /*
  * That's the init process which usually inherit
@@ -71,7 +72,7 @@ static inline int shared_fdtable(struct pstree_item *item)
 
 static inline bool is_alive_state(int state)
 {
-	return (state == TASK_ALIVE) || (state == TASK_STOPPED);
+	return (state == COMPEL_TASK_ALIVE) || (state == COMPEL_TASK_STOPPED);
 }
 
 static inline bool task_alive(struct pstree_item *i)
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index b52135e..3569715 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -2224,7 +2224,7 @@ int parse_threads(int pid, struct pid **_t, int *_n)
 			t[nr - 1].ns[0].virt = -1;
 		}
 		t[nr - 1].real = atoi(de->d_name);
-		t[nr - 1].state = TASK_THREAD;
+		t[nr - 1].state = COMPEL_TASK_THREAD;
 		nr++;
 	}
 
diff --git a/criu/pstree.c b/criu/pstree.c
index 833b3d0..13fb7ed 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -227,7 +227,7 @@ struct pstree_item *__alloc_pstree_item(bool rst)
 
 void init_pstree_helper(struct pstree_item *ret)
 {
-	ret->pid->state = TASK_HELPER;
+	ret->pid->state = COMPEL_TASK_HELPER;
 	rsti(ret)->clone_flags = CLONE_FILES | CLONE_FS;
 	task_entries->nr_helpers++;
 }
@@ -432,7 +432,7 @@ struct pstree_item *lookup_create_item(pid_t pid)
 	node = lookup_create_pid(pid, NULL);
 	if (!node)
 		return NULL;
-	BUG_ON(node->state == TASK_THREAD);
+	BUG_ON(node->state == COMPEL_TASK_THREAD);
 
 	return node->item;
 }
@@ -500,7 +500,7 @@ static int read_pstree_image(pid_t *pid_max)
 		pi = lookup_create_item(e->pid);
 		if (pi == NULL)
 			break;
-		BUG_ON(pi->pid->state != TASK_UNDEF);
+		BUG_ON(pi->pid->state != COMPEL_TASK_UNDEF);
 
 		/*
 		 * All pids should be added in the tree to be able to find
@@ -522,7 +522,7 @@ static int read_pstree_image(pid_t *pid_max)
 		pi->sid = e->sid;
 		if (e->sid > *pid_max)
 			*pid_max = e->sid;
-		pi->pid->state = TASK_ALIVE;
+		pi->pid->state = COMPEL_TASK_ALIVE;
 
 		if (e->ppid == 0) {
 			if (root_item) {
@@ -537,7 +537,7 @@ static int read_pstree_image(pid_t *pid_max)
 			struct pstree_item *parent;
 
 			pid = pstree_pid_by_virt(e->ppid);
-			if (!pid || pid->state == TASK_UNDEF || pid->state == TASK_THREAD) {
+			if (!pid || pid->state == COMPEL_TASK_UNDEF || pid->state == COMPEL_TASK_THREAD) {
 				pr_err("Can't find a parent for %d\n", pi->pid->ns[0].virt);
 				pstree_entry__free_unpacked(e, NULL);
 				xfree(pi);
@@ -558,7 +558,7 @@ static int read_pstree_image(pid_t *pid_max)
 			struct pid *node;
 			pi->threads[i].real = -1;
 			pi->threads[i].ns[0].virt = e->threads[i];
-			pi->threads[i].state = TASK_THREAD;
+			pi->threads[i].state = COMPEL_TASK_THREAD;
 			pi->threads[i].item = NULL;
 			if (i == 0)
 				continue; /* A thread leader is in a tree already */
@@ -639,7 +639,7 @@ static int prepare_pstree_ids(void)
 
 		leader = pstree_item_by_virt(item->sid);
 		BUG_ON(leader == NULL);
-		if (leader->pid->state != TASK_UNDEF) {
+		if (leader->pid->state != COMPEL_TASK_UNDEF) {
 			pid_t pid;
 
 			pid = get_free_pid();
@@ -697,7 +697,7 @@ static int prepare_pstree_ids(void)
 		if (!item->parent) /* skip the root task */
 			continue;
 
-		if (item->pid->state == TASK_HELPER)
+		if (item->pid->state == COMPEL_TASK_HELPER)
 			continue;
 
 		if (item->sid != item->pid->ns[0].virt) {
@@ -740,8 +740,8 @@ static int prepare_pstree_ids(void)
 			continue;
 
 		pid = pstree_pid_by_virt(item->pgid);
-		if (pid->state != TASK_UNDEF) {
-			BUG_ON(pid->state == TASK_THREAD);
+		if (pid->state != COMPEL_TASK_UNDEF) {
+			BUG_ON(pid->state == COMPEL_TASK_THREAD);
 			rsti(item)->pgrp_leader = pid->item;
 			continue;
 		}
@@ -982,7 +982,7 @@ struct pstree_item *pstree_item_by_virt(pid_t virt)
 	pid = pstree_pid_by_virt(virt);
 	if (pid == NULL)
 		return NULL;
-	BUG_ON(pid->state == TASK_THREAD);
+	BUG_ON(pid->state == COMPEL_TASK_THREAD);
 
 	return pid->item;
 }
diff --git a/criu/seccomp.c b/criu/seccomp.c
index c5e7a7d..cf10351 100644
--- a/criu/seccomp.c
+++ b/criu/seccomp.c
@@ -49,7 +49,7 @@ static int collect_filter_for_pstree(struct pstree_item *item)
 	struct sock_filter buf[BPF_MAXINSNS];
 	void *m;
 
-	if (item->pid->state == TASK_DEAD ||
+	if (item->pid->state == COMPEL_TASK_DEAD ||
 	    dmpi(item)->pi_creds->s.seccomp_mode != SECCOMP_MODE_FILTER)
 		return 0;
 
diff --git a/criu/seize.c b/criu/seize.c
index d5079ca..7908e67 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -505,8 +505,8 @@ static int collect_children(struct pstree_item *item)
 			continue;
 		}
 
-		if (ret == TASK_ZOMBIE)
-			ret = TASK_DEAD;
+		if (ret == COMPEL_TASK_ZOMBIE)
+			ret = COMPEL_TASK_DEAD;
 		else
 			processes_to_wait--;
 
@@ -530,7 +530,7 @@ static void unseize_task_and_threads(const struct pstree_item *item, int st)
 {
 	int i;
 
-	if (item->pid->state == TASK_DEAD)
+	if (item->pid->state == COMPEL_TASK_DEAD)
 		return;
 
 	/*
@@ -540,7 +540,7 @@ static void unseize_task_and_threads(const struct pstree_item *item, int st)
 
 	compel_resume_task(item->pid->real, item->pid->state, st);
 
-	if (st == TASK_DEAD)
+	if (st == COMPEL_TASK_DEAD)
 		return;
 
 	for (i = 1; i < item->nr_threads; i++)
@@ -555,7 +555,7 @@ static void pstree_wait(struct pstree_item *root_item)
 
 	for_each_pstree_item(item) {
 
-		if (item->pid->state == TASK_DEAD)
+		if (item->pid->state == COMPEL_TASK_DEAD)
 			continue;
 
 		for (i = 0; i < item->nr_threads; i++) {
@@ -587,7 +587,7 @@ void pstree_switch_state(struct pstree_item *root_item, int st)
 	if (!root_item)
 		return;
 
-	if (st != TASK_DEAD)
+	if (st != COMPEL_TASK_DEAD)
 		freezer_restore_state();
 
 	/*
@@ -602,7 +602,7 @@ void pstree_switch_state(struct pstree_item *root_item, int st)
 	for_each_pstree_item(item)
 		unseize_task_and_threads(item, st);
 
-	if (st == TASK_DEAD)
+	if (st == COMPEL_TASK_DEAD)
 		pstree_wait(root_item);
 }
 
@@ -684,7 +684,7 @@ static int collect_threads(struct pstree_item *item)
 	if (ret < 0)
 		goto err;
 
-	if ((item->pid->state == TASK_DEAD) && (nr_threads > 1)) {
+	if ((item->pid->state == COMPEL_TASK_DEAD) && (nr_threads > 1)) {
 		pr_err("Zombies with threads are not supported\n");
 		goto err;
 	}
@@ -728,8 +728,8 @@ static int collect_threads(struct pstree_item *item)
 			continue;
 		}
 
-		if (ret == TASK_ZOMBIE)
-			ret = TASK_DEAD;
+		if (ret == COMPEL_TASK_ZOMBIE)
+			ret = COMPEL_TASK_DEAD;
 		else
 			processes_to_wait--;
 
@@ -738,7 +738,7 @@ static int collect_threads(struct pstree_item *item)
 		item->threads[item->nr_threads].item = NULL;
 		item->nr_threads++;
 
-		if (ret == TASK_DEAD) {
+		if (ret == COMPEL_TASK_DEAD) {
 			pr_err("Zombie thread not supported\n");
 			goto err;
 		}
@@ -746,7 +746,7 @@ static int collect_threads(struct pstree_item *item)
 		if (!creds_dumpable(dmpi(item)->pi_creds, &t_creds))
 			goto err;
 
-		if (ret == TASK_STOPPED) {
+		if (ret == COMPEL_TASK_STOPPED) {
 			nr_stopped++;
 		}
 	}
@@ -812,7 +812,7 @@ static int collect_task(struct pstree_item *item)
 	if (ret < 0)
 		goto err_close;
 
-	if ((item->pid->state == TASK_DEAD) && !list_empty(&item->children)) {
+	if ((item->pid->state == COMPEL_TASK_DEAD) && !list_empty(&item->children)) {
 		pr_err("Zombie with children?! O_o Run, run, run!\n");
 		goto err_close;
 	}
@@ -859,8 +859,8 @@ int collect_pstree(void)
 	if (ret < 0)
 		goto err;
 
-	if (ret == TASK_ZOMBIE)
-		ret = TASK_DEAD;
+	if (ret == COMPEL_TASK_ZOMBIE)
+		ret = COMPEL_TASK_DEAD;
 	else
 		processes_to_wait--;
 
diff --git a/criu/tty.c b/criu/tty.c
index 17d19f4..b361f3a 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -2066,7 +2066,7 @@ static int tty_dump_queued_data(void)
 			break;
 	}
 
-	if (ret || opts.final_state != TASK_DEAD) {
+	if (ret || opts.final_state != COMPEL_TASK_DEAD) {
 		list_for_each_entry(dinfo, &all_ptys, list)
 			tty_do_writeback_queued_data(dinfo);
 	}
-- 
2.9.3



More information about the CRIU mailing list