[CRIU] [PATCH v3 14/19] page-xfer: make connect_to_page_server return socket fd

Mike Rapoport rppt at linux.vnet.ibm.com
Tue Nov 15 08:57:23 PST 2016


It will used by lazy-pages daemon to enable polling for reception of page
data from remote dump

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/cr-dump.c   |  4 ++--
 criu/page-xfer.c |  2 +-
 criu/uffd.c      | 13 ++++++++++++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 23d3eef..468df01 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -1554,7 +1554,7 @@ int cr_pre_dump_tasks(pid_t pid)
 	if (vdso_init())
 		goto err;
 
-	if (connect_to_page_server())
+	if (connect_to_page_server() < 0)
 		goto err;
 
 	if (setup_alarm_handler())
@@ -1746,7 +1746,7 @@ int cr_dump_tasks(pid_t pid)
 			goto err;
 	}
 
-	if (connect_to_page_server())
+	if (connect_to_page_server() < 0)
 		goto err;
 
 	if (setup_alarm_handler())
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 27800c4..6ca88f3 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -843,7 +843,7 @@ out:
 	 * on urgent data is the smartest mode ever.
 	 */
 	tcp_cork(page_server_sk, true);
-	return 0;
+	return page_server_sk;
 }
 
 int disconnect_from_page_server(void)
diff --git a/criu/uffd.c b/criu/uffd.c
index d9aa98d..3750f5b 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -853,6 +853,17 @@ close_uffd:
 	return -1;
 }
 
+static int prepare_page_server_socket(void)
+{
+	int sk;
+
+	sk = connect_to_page_server();
+	if (sk < 0)
+		return -1;
+
+	return 0;
+}
+
 int cr_lazy_pages(bool daemon)
 {
 	struct epoll_event *events;
@@ -897,7 +908,7 @@ int cr_lazy_pages(bool daemon)
 	if (prepare_uffds(lazy_sk, epollfd))
 		return -1;
 
-	if (connect_to_page_server())
+	if (prepare_page_server_socket())
 		return -1;
 
 	ret = handle_requests(epollfd, events);
-- 
1.9.1



More information about the CRIU mailing list