Commit 82b7c07c authored by Pavel Emelyanov's avatar Pavel Emelyanov

show: Fix 'all' mode showing

After we removed the pid from pstree image file the -t or -p option for show
command no longer makes sense. Make 'show' mode rely on -D option to find out
where to find the root (i.e. pstree.img) file.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 0c5dc42d
...@@ -556,11 +556,11 @@ err: ...@@ -556,11 +556,11 @@ err:
return ret; return ret;
} }
static int cr_show_all(unsigned long pid, struct cr_options *opts) static int cr_show_all(struct cr_options *opts)
{ {
struct pstree_item *item = NULL; struct pstree_item *item = NULL;
LIST_HEAD(pstree_list); LIST_HEAD(pstree_list);
int i, ret = -1, fd; int i, ret = -1, fd, pid;
fd = open_image_ro(CR_FD_PSTREE); fd = open_image_ro(CR_FD_PSTREE);
if (fd < 0) if (fd < 0)
...@@ -582,6 +582,7 @@ static int cr_show_all(unsigned long pid, struct cr_options *opts) ...@@ -582,6 +582,7 @@ static int cr_show_all(unsigned long pid, struct cr_options *opts)
close(fd); close(fd);
pid = list_first_entry(&pstree_list, struct pstree_item, list)->pid;
ret = try_show_namespaces(pid); ret = try_show_namespaces(pid);
if (ret) if (ret)
goto out; goto out;
...@@ -645,10 +646,10 @@ out: ...@@ -645,10 +646,10 @@ out:
return ret; return ret;
} }
int cr_show(unsigned long pid, struct cr_options *opts) int cr_show(struct cr_options *opts)
{ {
if (opts->show_dump_file) if (opts->show_dump_file)
return cr_parse_file(opts); return cr_parse_file(opts);
return cr_show_all(pid, opts); return cr_show_all(opts);
} }
...@@ -160,6 +160,8 @@ static struct cr_fdset *alloc_cr_fdset(int nr) ...@@ -160,6 +160,8 @@ static struct cr_fdset *alloc_cr_fdset(int nr)
return NULL; return NULL;
} }
for (i = 0; i < nr; i++)
cr_fdset->_fds[i] = -1;
cr_fdset->fd_nr = nr; cr_fdset->fd_nr = nr;
return cr_fdset; return cr_fdset;
} }
...@@ -358,9 +360,6 @@ int main(int argc, char *argv[]) ...@@ -358,9 +360,6 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
if (!pid && (action != 'c') && (action != 's' || !opts.show_dump_file))
goto opt_pid_missing;
if (strcmp(argv[1], "dump") && if (strcmp(argv[1], "dump") &&
strcmp(argv[1], "restore") && strcmp(argv[1], "restore") &&
strcmp(argv[1], "show") && strcmp(argv[1], "show") &&
...@@ -371,13 +370,17 @@ int main(int argc, char *argv[]) ...@@ -371,13 +370,17 @@ int main(int argc, char *argv[])
switch (action) { switch (action) {
case 'd': case 'd':
if (!pid)
goto opt_pid_missing;
ret = cr_dump_tasks(pid, &opts); ret = cr_dump_tasks(pid, &opts);
break; break;
case 'r': case 'r':
if (!pid)
goto opt_pid_missing;
ret = cr_restore_tasks(pid, &opts); ret = cr_restore_tasks(pid, &opts);
break; break;
case 's': case 's':
ret = cr_show(pid, &opts); ret = cr_show(&opts);
break; break;
case 'c': case 'c':
ret = cr_check(); ret = cr_check();
...@@ -393,13 +396,13 @@ usage: ...@@ -393,13 +396,13 @@ usage:
pr_msg("\nUsage:\n"); pr_msg("\nUsage:\n");
pr_msg(" %s dump [-c] -p|-t pid [-n ns]\n", argv[0]); pr_msg(" %s dump [-c] -p|-t pid [-n ns]\n", argv[0]);
pr_msg(" %s restore -p|-t pid [-n ns]\n", argv[0]); pr_msg(" %s restore -p|-t pid [-n ns]\n", argv[0]);
pr_msg(" %s show [-c] (-p|-t pid)|(-f file)\n", argv[0]); pr_msg(" %s show [-c] (-D dir)|(-f file)\n", argv[0]);
pr_msg(" %s check\n", argv[0]); pr_msg(" %s check\n", argv[0]);
pr_msg("\nCommands:\n"); pr_msg("\nCommands:\n");
pr_msg(" dump checkpoint a process identified by pid\n"); pr_msg(" dump checkpoint a process identified by pid\n");
pr_msg(" restore restore a process identified by pid\n"); pr_msg(" restore restore a process identified by pid\n");
pr_msg(" show show dump contents of a process identified by pid\n"); pr_msg(" show show dump file(s) contents\n");
pr_msg(" check checks whether the kernel support is up-to-date\n"); pr_msg(" check checks whether the kernel support is up-to-date\n");
pr_msg("\nGeneral parameters:\n"); pr_msg("\nGeneral parameters:\n");
pr_msg(" -p checkpoint/restore only a single process identified by pid\n"); pr_msg(" -p checkpoint/restore only a single process identified by pid\n");
...@@ -412,7 +415,7 @@ usage: ...@@ -412,7 +415,7 @@ usage:
pr_msg(" supported: uts, ipc\n"); pr_msg(" supported: uts, ipc\n");
pr_msg("\nAdditional common parameters:\n"); pr_msg("\nAdditional common parameters:\n");
pr_msg(" -D dir save checkpoint files in specified directory\n"); pr_msg(" -D dir specifis directory where checkpoint files are/to be located\n");
pr_msg(" -v [num] set logging level\n"); pr_msg(" -v [num] set logging level\n");
pr_msg(" 0 - silent (only error messages)\n"); pr_msg(" 0 - silent (only error messages)\n");
pr_msg(" 1 - informative (default)\n"); pr_msg(" 1 - informative (default)\n");
......
...@@ -135,7 +135,7 @@ extern struct cr_fdset *glob_fdset; ...@@ -135,7 +135,7 @@ extern struct cr_fdset *glob_fdset;
int cr_dump_tasks(pid_t pid, const struct cr_options *opts); int cr_dump_tasks(pid_t pid, const struct cr_options *opts);
int cr_restore_tasks(pid_t pid, struct cr_options *opts); int cr_restore_tasks(pid_t pid, struct cr_options *opts);
int cr_show(unsigned long pid, struct cr_options *opts); int cr_show(struct cr_options *opts);
int convert_to_elf(char *elf_path, int fd_core); int convert_to_elf(char *elf_path, int fd_core);
int cr_check(void); int cr_check(void);
......
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