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

This patches improves execution of zdtm tests.

It's really like in VZ.
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 b6017657
...@@ -1213,7 +1213,7 @@ static int restore_task_with_children(int my_pid) ...@@ -1213,7 +1213,7 @@ static int restore_task_with_children(int my_pid)
return restore_one_task(my_pid); return restore_one_task(my_pid);
} }
static int restore_root_task(int fd) static int restore_root_task(int fd, bool detach)
{ {
struct pstree_entry e; struct pstree_entry e;
int ret, i; int ret, i;
...@@ -1240,11 +1240,12 @@ static int restore_root_task(int fd) ...@@ -1240,11 +1240,12 @@ static int restore_root_task(int fd)
pr_info("Go on!!!\n"); pr_info("Go on!!!\n");
cr_wait_set(&task_entries->start, 1); cr_wait_set(&task_entries->start, 1);
wait(NULL); if (!detach)
wait(NULL);
return 0; return 0;
} }
static int restore_all_tasks(pid_t pid) static int restore_all_tasks(pid_t pid, bool detach)
{ {
int pstree_fd; int pstree_fd;
u32 type = 0; u32 type = 0;
...@@ -1256,7 +1257,7 @@ static int restore_all_tasks(pid_t pid) ...@@ -1256,7 +1257,7 @@ static int restore_all_tasks(pid_t pid)
if (prepare_shared(pstree_fd)) if (prepare_shared(pstree_fd))
return -1; return -1;
return restore_root_task(pstree_fd); return restore_root_task(pstree_fd, detach);
} }
static long restorer_get_vma_hint(pid_t pid, struct list_head *self_vma_list, long vma_len) static long restorer_get_vma_hint(pid_t pid, struct list_head *self_vma_list, long vma_len)
...@@ -1623,5 +1624,5 @@ int cr_restore_tasks(pid_t pid, struct cr_options *opts) ...@@ -1623,5 +1624,5 @@ int cr_restore_tasks(pid_t pid, struct cr_options *opts)
if (opts->leader_only) if (opts->leader_only)
return restore_one_task(pid); return restore_one_task(pid);
return restore_all_tasks(pid); return restore_all_tasks(pid, opts->restore_detach);
} }
...@@ -218,7 +218,7 @@ int main(int argc, char *argv[]) ...@@ -218,7 +218,7 @@ int main(int argc, char *argv[])
int action = -1; int action = -1;
int log_inited = 0; int log_inited = 0;
static const char short_opts[] = "f:p:t:hcD:o:"; static const char short_opts[] = "df:p:t:hcD:o:";
BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE); BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
...@@ -250,6 +250,9 @@ int main(int argc, char *argv[]) ...@@ -250,6 +250,9 @@ int main(int argc, char *argv[])
case 'f': case 'f':
opts.show_dump_file = optarg; opts.show_dump_file = optarg;
break; break;
case 'd':
opts.restore_detach = true;
break;
case 'D': case 'D':
if (chdir(optarg)) { if (chdir(optarg)) {
pr_perror("can't change working directory"); pr_perror("can't change working directory");
...@@ -322,6 +325,7 @@ usage: ...@@ -322,6 +325,7 @@ usage:
printk(" -c in case of checkpoint -- continue running the process after\n" printk(" -c in case of checkpoint -- continue running the process after\n"
" checkpoint complete, in case of showing file contents --\n" " checkpoint complete, in case of showing file contents --\n"
" show contents of pages dumped in hexdump format\n"); " show contents of pages dumped in hexdump format\n");
printk(" -d detach after restore\n");
printk("\nAdditional common parameters:\n"); printk("\nAdditional common parameters:\n");
printk(" -D dir save checkpoint files in specified directory\n"); printk(" -D dir save checkpoint files in specified directory\n");
......
...@@ -40,6 +40,7 @@ struct cr_options { ...@@ -40,6 +40,7 @@ struct cr_options {
enum cr_task_state final_state; enum cr_task_state final_state;
bool show_pages_content; bool show_pages_content;
char *show_dump_file; char *show_dump_file;
bool restore_detach;
}; };
/* file descriptors template */ /* file descriptors template */
......
...@@ -44,11 +44,9 @@ run_test() ...@@ -44,11 +44,9 @@ run_test()
echo Waiting... echo Waiting...
sleep 1 sleep 1
done done
setsid $CRTOOLS restore -D $ddump -o restore.log -t $pid & setsid $CRTOOLS restore -D $ddump -o restore.log -d -t $pid || return 1
sleep 1
ls -l /proc/$pid/fd/ ls -l /proc/$pid/fd/
make -C $tdir $tname.out make -C $tdir $tname.out
wait || return 1
for i in `seq 5`; do for i in `seq 5`; do
test -f $test.out && break; test -f $test.out && break;
echo Waiting... echo Waiting...
......
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