Commit 9e0b308a authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

dump/restore: Rework final-state switch

Remove CR_TASK_XXX states, use the TASK_XXX ones (for image). This is
required to unseize tasks properly in the next patches.

Plus, make sure that pstree_list and the seized set coincide (i.e.
handle error in collect_task).
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 0afad031
......@@ -845,7 +845,7 @@ static int get_children(struct pstree_item *item)
return parse_children(item, &item->children, &item->nr_children);
}
static void unseize_task_and_threads(struct pstree_item *item, enum cr_task_state st)
static void unseize_task_and_threads(struct pstree_item *item, int st)
{
int i;
......@@ -900,7 +900,7 @@ err:
if (item->pid == item->threads[i])
continue;
unseize_task(item->threads[i], CR_TASK_STOP /* FIXME */);
unseize_task(item->threads[i], TASK_ALIVE);
}
return -1;
......@@ -957,6 +957,7 @@ static struct pstree_item *collect_task(pid_t pid, pid_t ppid, struct list_head
err_close:
close_pid_proc();
unseize_task(pid, item->state);
err_free:
xfree(item->children);
xfree(item->threads);
......
......@@ -308,13 +308,13 @@ int main(int argc, char *argv[])
memzero_p(&zero_page_entry);
/* Default options */
opts.final_state = CR_TASK_KILL;
opts.final_state = TASK_DEAD;
for (opt = getopt_long(argc - 1, argv + 1, short_opts, NULL, &idx); opt != -1;
opt = getopt_long(argc - 1, argv + 1, short_opts, NULL, &idx)) {
switch (opt) {
case 's':
opts.final_state = CR_TASK_STOP;
opts.final_state = TASK_STOPPED;
break;
case 'p':
pid = atoi(optarg);
......
......@@ -47,13 +47,8 @@ enum {
CR_FD_MAX
};
enum cr_task_state {
CR_TASK_STOP,
CR_TASK_KILL,
};
struct cr_options {
enum cr_task_state final_state;
int final_state;
char *show_dump_file;
bool leader_only;
bool show_pages_content;
......
......@@ -33,7 +33,7 @@
#define PTRACE_O_TRACEEXIT 0x00000040
extern int seize_task(pid_t pid, pid_t ppid);
extern int unseize_task(pid_t pid, enum cr_task_state st);
extern int unseize_task(pid_t pid, int state);
extern int ptrace_peek_area(pid_t pid, void *dst, void *addr, long bytes);
extern int ptrace_poke_area(pid_t pid, void *src, void *addr, long bytes);
extern int ptrace_swap_area(pid_t pid, void *dst, void *src, long bytes);
......
......@@ -20,12 +20,14 @@
#include "ptrace.h"
#include "proc_parse.h"
int unseize_task(pid_t pid, enum cr_task_state st)
int unseize_task(pid_t pid, int st)
{
if (st == CR_TASK_KILL)
if (st == TASK_DEAD)
kill(pid, SIGKILL);
else if (st == CR_TASK_STOP)
else if (st == TASK_STOPPED)
kill(pid, SIGSTOP);
else if (st == TASK_ALIVE)
/* do nothing */ ;
else
pr_err("Unknown final state %d\n", st);
......@@ -110,7 +112,7 @@ int seize_task(pid_t pid, pid_t ppid)
pr_err("SEIZE %d: unsupported stop signal %d\n", pid, si.si_signo);
err:
unseize_task(pid, CR_TASK_STOP);
unseize_task(pid, TASK_STOPPED);
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment