[CRIU] [PATCH 4/5] uffd: Hide page server socket back

Mike Rapoport mike.rapoport at gmail.com
Mon Nov 21 04:51:12 PST 2016


On Mon, Nov 21, 2016 at 02:26:56PM +0300, Pavel Emelyanov wrote:
> With epoll helpers in util we can stop exposing the
> page-server socket to the oter world.

to the rest of the world...

> 
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>

Acked-by: Mike Rapoport <rppt at linux.vnet.ibm.com>

> ---
>  criu/cr-dump.c           |  4 ++--
>  criu/include/page-xfer.h |  4 ++--
>  criu/page-xfer.c         | 24 +++++++++++++++++++++---
>  criu/uffd.c              | 23 +----------------------
>  4 files changed, 26 insertions(+), 29 deletions(-)
> 
> diff --git a/criu/cr-dump.c b/criu/cr-dump.c
> index 468df01..6982911 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() < 0)
> +	if (connect_to_page_server_to_send() < 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() < 0)
> +	if (connect_to_page_server_to_send() < 0)
>  		goto err;
>  
>  	if (setup_alarm_handler())
> diff --git a/criu/include/page-xfer.h b/criu/include/page-xfer.h
> index 35425f1..dfe43e5 100644
> --- a/criu/include/page-xfer.h
> +++ b/criu/include/page-xfer.h
> @@ -37,7 +37,8 @@ extern int open_page_xfer(struct page_xfer *xfer, int fd_type, long id);
>  struct page_pipe;
>  extern int page_xfer_dump_pages(struct page_xfer *, struct page_pipe *,
>  				unsigned long off, bool dump_lazy);
> -extern int connect_to_page_server(void);
> +extern int connect_to_page_server_to_send(void);
> +extern int connect_to_page_server_to_recv(int epfd);
>  extern int disconnect_from_page_server(void);
>  
>  extern int check_parent_page_xfer(int fd_type, long id);
> @@ -60,6 +61,5 @@ extern int receive_remote_pages(int len, void *buf);
>  typedef int (*ps_async_read_complete)(int pid, unsigned long vaddr, int nr_pages, void *);
>  extern int page_server_start_async_read(void *buf, int nr_pages,
>  		ps_async_read_complete complete, void *priv);
> -extern int page_server_async_read(void);
>  
>  #endif /* __CR_PAGE_XFER__H__ */
> diff --git a/criu/page-xfer.c b/criu/page-xfer.c
> index 234c38d..78a25f5 100644
> --- a/criu/page-xfer.c
> +++ b/criu/page-xfer.c
> @@ -822,7 +822,7 @@ no_server:
>  	return ret;
>  }
>  
> -int connect_to_page_server(void)
> +static int connect_to_page_server(void)
>  {
>  	if (!opts.use_page_server)
>  		return 0;
> @@ -843,7 +843,12 @@ out:
>  	 * on urgent data is the smartest mode ever.
>  	 */
>  	tcp_cork(page_server_sk, true);
> -	return page_server_sk;
> +	return 0;
> +}
> +
> +int connect_to_page_server_to_send(void)
> +{
> +	return connect_to_page_server();
>  }
>  
>  int disconnect_from_page_server(void)
> @@ -930,7 +935,7 @@ int page_server_start_async_read(void *buf, int nr_pages,
>   * for sure the next time socket event will occur we'll get page data
>   * related to info we've just received
>   */
> -int page_server_async_read(void)
> +static int page_server_async_read(struct epoll_rfd *f)
>  {
>  	struct ps_async_read *ar;
>  	int ret, need;
> @@ -972,6 +977,19 @@ int page_server_async_read(void)
>  	return ret;
>  }
>  
> +static struct epoll_rfd ps_rfd;
> +
> +int connect_to_page_server_to_recv(int epfd)
> +{
> +	if (connect_to_page_server())
> +		return -1;
> +
> +	ps_rfd.fd = page_server_sk;
> +	ps_rfd.revent = page_server_async_read;
> +
> +	return epoll_add_rfd(epfd, &ps_rfd);
> +}
> +
>  int request_remote_pages(int pid, unsigned long addr, int nr_pages)
>  {
>  	struct page_server_iov pi = {
> diff --git a/criu/uffd.c b/criu/uffd.c
> index c16f191..a3c72aa 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -849,27 +849,6 @@ close_uffd:
>  	return -1;
>  }
>  
> -static int page_server_event(struct epoll_rfd *lpfd)
> -{
> -	return page_server_async_read();
> -}
> -
> -static struct epoll_rfd page_server_sk_fd;
> -
> -static int prepare_page_server_socket(int epollfd)
> -{
> -	int sk;
> -
> -	sk = connect_to_page_server();
> -	if (sk < 0)
> -		return -1;
> -
> -	page_server_sk_fd.revent = page_server_event;
> -	page_server_sk_fd.fd = sk;
> -
> -	return epoll_add_rfd(epollfd, &page_server_sk_fd);
> -}
> -
>  int cr_lazy_pages(bool daemon)
>  {
>  	struct epoll_event *events;
> @@ -917,7 +896,7 @@ int cr_lazy_pages(bool daemon)
>  		return -1;
>  
>  	if (opts.use_page_server) {
> -		if (prepare_page_server_socket(epollfd))
> +		if (connect_to_page_server_to_recv(epollfd))
>  			return -1;
>  	}
>  
> -- 
> 2.5.0
> 


More information about the CRIU mailing list