[CRIU] Re: [PATCH cr 3/5] parasite: create unix socket in parasite for transfering fd

Pavel Emelyanov xemul at parallels.com
Tue Jan 31 06:49:54 EST 2012


On 01/31/2012 02:16 PM, Andrey Vagin wrote:
> 
> Before we used absolute pathes to images and wrote logging messages in
> stderr of a target process.
> 
> Now we are able to create fd and send it to parasite.
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  include/parasite.h |   11 ++++++
>  parasite-syscall.c |   95 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  parasite.c         |   45 ++++++++++++++++++++++++-
>  3 files changed, 150 insertions(+), 1 deletions(-)
> 

> +	PARASITE_CMD_OPEN_SOCK,

PARASITE_CMD_INIT

> +	PARASITE_CMD_RECV_LOGFD,

PARASITE_CMD_RECV_FDS

This one should pass an array of int-s. Currently index FD_LOG = 0 should be 
supported, then I have plans for index FD_IMGDIR = 1 one.

Please, make it ready for this change now.

> +	PARASITE_CMD_FINI,

This one is OK.

> +static int parasite_send_fd(struct parasite_ctl *ctl, int fd)
> +{
> +	struct sockaddr_un saddr;
> +	int sun_len, ret;
> +	int sock;
> +
> +	sun_len = get_socket_name(&saddr, ctl->pid);
> +
> +	sock = socket(PF_UNIX, SOCK_DGRAM, 0);
> +	if (sock < 0) {
> +		pr_perror("Can't create socket");
> +		return -1;
> +	}
> +
> +	if (send_fd(sock, &saddr, sun_len, fd) < 0) {
> +		pr_perror("Can't send file descriptor");
> +		return -1;
> +	}

Close socket lost?

> +	return 0;
> +}


More information about the CRIU mailing list