diff --git a/criu/include/pstree.h b/criu/include/pstree.h index b7299c313..7cf4be9cf 100644 --- a/criu/include/pstree.h +++ b/criu/include/pstree.h @@ -100,6 +100,7 @@ extern struct pstree_item *pstree_item_next(struct pstree_item *item); extern bool restore_before_setsid(struct pstree_item *child); extern int prepare_pstree(void); +extern int prepare_dummy_pstree(void); extern int dump_pstree(struct pstree_item *root_item); diff --git a/criu/pstree.c b/criu/pstree.c index 9b2d171dc..e9ddc6aeb 100644 --- a/criu/pstree.c +++ b/criu/pstree.c @@ -16,6 +16,7 @@ #include "util.h" #include "protobuf.h" #include "images/pstree.pb-c.h" +#include "crtools.h" struct pstree_item *root_item; static struct rb_root pid_root_rb; @@ -950,6 +951,22 @@ int prepare_pstree(void) return ret; } +int prepare_dummy_pstree(void) +{ + pid_t dummy = 0; + + if (check_img_inventory() == -1) + return -1; + + if (prepare_task_entries() == -1) + return -1; + + if (read_pstree_image(&dummy) == -1) + return -1; + + return 0; +} + bool restore_before_setsid(struct pstree_item *child) { int csid = child->born_sid == -1 ? child->sid : child->born_sid; diff --git a/criu/uffd.c b/criu/uffd.c index cb6e9e203..41ed48062 100644 --- a/criu/uffd.c +++ b/criu/uffd.c @@ -781,21 +781,6 @@ out: } -static int lazy_pages_prepare_pstree(void) -{ - if (check_img_inventory() == -1) - return -1; - - /* Allocate memory for task_entries */ - if (prepare_task_entries() == -1) - return -1; - - if (prepare_pstree() == -1) - return -1; - - return 0; -} - static int prepare_epoll(int nr_fds, struct epoll_event **events) { int epollfd; @@ -915,7 +900,7 @@ int cr_lazy_pages(bool daemon) if (check_for_uffd()) return -1; - if (lazy_pages_prepare_pstree()) + if (prepare_dummy_pstree()) return -1; lazy_sk = prepare_lazy_socket();