Commit b6017657 authored by Andrey Vagin's avatar Andrey Vagin Committed by Cyrill Gorcunov

devide commands and options

./crtools CMD [options]
CMD may be show, restore, dump
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Acked-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent e1c1ca3c
......@@ -218,26 +218,22 @@ int main(int argc, char *argv[])
int action = -1;
int log_inited = 0;
static const char short_opts[] = "drsf:p:t:hcD:o:";
static const struct option long_opts[] = {
{ "dump", no_argument, NULL, 'd' },
{ "restore", no_argument, NULL, 'r' },
{ "show", no_argument, NULL, 's' },
{ NULL, no_argument, NULL, 0 }
};
static const char short_opts[] = "f:p:t:hcD:o:";
BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
if (argc < 3)
goto usage;
action = argv[1][0];
memzero_p(&zero_page_entry);
/* Default options */
opts.final_state = CR_TASK_KILL;
for (opt = getopt_long(argc, argv, short_opts, long_opts, &idx); opt != -1;
opt = getopt_long(argc, argv, short_opts, long_opts, &idx)) {
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 'p':
pid = atoi(optarg);
......@@ -247,15 +243,6 @@ int main(int argc, char *argv[])
pid = atoi(optarg);
opts.leader_only = false;
break;
case 'd':
action = opt;
break;
case 'r':
action = opt;
break;
case 's':
action = opt;
break;
case 'c':
opts.show_pages_content = true;
opts.final_state = CR_TASK_RUN;
......@@ -294,6 +281,13 @@ int main(int argc, char *argv[])
if (!pid && (action != 's' || !opts.show_dump_file))
goto opt_pid_missing;
if (strcmp(argv[1], "dump") &&
strcmp(argv[1], "restore") &&
strcmp(argv[1], "show")) {
pr_err("Unknown command");
goto usage;
}
switch (action) {
case 'd':
ret = cr_dump_tasks(pid, &opts);
......@@ -313,14 +307,15 @@ int main(int argc, char *argv[])
usage:
printk("\nUsage:\n");
printk(" %s --dump|-d [-c] -p|-t pid\n", argv[0]);
printk(" %s --restore|-r -p|-t pid\n", argv[0]);
printk(" %s --show|-s [-c] (-p|-t pid)|(-f file)\n", argv[0]);
printk(" %s dump [-c] -p|-t pid\n", argv[0]);
printk(" %s restore -p|-t pid\n", argv[0]);
printk(" %s show [-c] (-p|-t pid)|(-f file)\n", argv[0]);
printk("\nCommands:\n");
printk(" dump checkpoint a process identified by pid\n");
printk(" restore restore a process identified by pid\n");
printk(" show show dump contents of a process identified by pid\n");
printk("\nGeneral parameters:\n");
printk(" --dump,-d checkpoint a process identified by pid\n");
printk(" --restore,-r restore a process identified by pid\n");
printk(" --show,-s show dump contents of a process identified by pid\n");
printk(" -p checkpoint/restore only a single process identified by pid\n");
printk(" -t checkpoint/restore the whole process tree identified by pid\n");
printk(" -f show contents of a checkpoint file\n");
......
......@@ -38,13 +38,13 @@ run_test()
ddump="dump/$tname/$pid"
mkdir -p $ddump
ls -l /proc/$pid/fd/
setsid $CRTOOLS -D $ddump -o dump.log -d -t $pid || return 1
setsid $CRTOOLS dump -D $ddump -o dump.log -t $pid || return 1
while :; do
killall -9 $tname &> /dev/null || break;
echo Waiting...
sleep 1
done
setsid $CRTOOLS -D $ddump -o restore.log -r -t $pid &
setsid $CRTOOLS restore -D $ddump -o restore.log -t $pid &
sleep 1
ls -l /proc/$pid/fd/
make -C $tdir $tname.out
......
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