[CRIU] [PATCH 1/3] Process Migration using Sockets (Rodrigo Bruno)

Pavel Emelyanov xemul at virtuozzo.com
Fri Feb 3 08:14:12 PST 2017


Sorry for long delay (again) in response...

I'm ready to merge the patches into criu-dev, and later, when we have
all this functionality tested by zdtm.py and code improved, I will merge
the code into master. But in order to facilitate the 1st merging (into
criu-dev branch) happen, can you do some cosmetic changes (mostly text 
fixes and splits)?

Comments are inline.

Later (after merge) I'll send more comments about what should be done on
top of this set to make criu-dev -> master merge.

>     This patch introduces the --remote option and the necessary code
> changes to
>     support it. This leaves user the option to decide if the checkpoint
> data is to
>     be stored on disk or sent through the network (through the image-proxy).
>     The latter forwards the data to the destination node where image-cache
>     receives it.
> 
>     The overall communication is performed as follows:
>     src_node CRIU dump -> (sends images through UNIX sockets) ->      
> image-proxy
>                                                                                |
>                                                                                V
>     dst_node: CRIU restore <- (receives images through UNIX sockets)<-
> image-cache
> 
>     Communication between image-proxy and image-cache is done through a
> single
>     TCP connection.
> 
>     Running criu with --remote option is like this:
> 
>     dst_node# criu image-cache -d --port <port> -o /tmp/image-cache.log
>     --local-cache-path <local_cache_path> ...

But in crtools.c there's no such option. So I assume that this description
needs fixing.

> diff --git a/criu/include/image.h b/criu/include/image.h
> index 1c22a4f..c2b612e 100644
> --- a/criu/include/image.h
> +++ b/criu/include/image.h
> @@ -105,6 +105,7 @@ extern bool img_common_magic;
>  #define O_DUMP		(O_WRONLY | O_CREAT | O_TRUNC)
>  #define O_SHOW		(O_RDONLY | O_NOBUF)
>  #define O_RSTR		(O_RDONLY)
> +#define O_FORCE_LOCAL	(O_SYNC)

Please, send the O_FORCE_LOCAL flag and image descs marked with it (3 hunks)
as separate patch.

>  struct cr_img {
>  	union {
> diff --git a/criu/include/img-remote.h b/criu/include/img-remote.h

> @@ -501,7 +528,11 @@ static int init_pagemaps(struct page_read *pr)
>  	off_t fsize;
>  	int nr_pmes, nr_realloc;
> 
> -	fsize = img_raw_size(pr->pmi);
> +	if (!opts.remote)
> +		fsize = img_raw_size(pr->pmi);
> +	else
> +		fsize = 1024; /*FIXME*/

Please, add some more words describing what is to be FIXME-ed.

> +
>  	if (fsize < 0)
>  		return -1;
> 
> diff --git a/criu/protobuf-desc.c b/criu/protobuf-desc.c
> index 41c2080..bfe00c5 100644
> --- a/criu/protobuf-desc.c
> +++ b/criu/protobuf-desc.c
> @@ -62,6 +62,7 @@
>  #include "images/seccomp.pb-c.h"
>  #include "images/binfmt-misc.pb-c.h"
>  #include "images/autofs.pb-c.h"
> +#include "images/remote-image.pb-c.h"
> 
>  struct cr_pb_message_desc cr_pb_descs[PB_MAX];
> 
> diff --git a/criu/sk-queue.c b/criu/sk-queue.c
> index 7b1da2d..f92d020 100644
> --- a/criu/sk-queue.c
> +++ b/criu/sk-queue.c
> @@ -27,7 +27,7 @@
>  struct sk_packet {
>  	struct list_head	list;
>  	SkPacketEntry		*entry;
> -	off_t			img_off;
> +	char        		*data;
>  };
> 
>  static LIST_HEAD(packets_list);
> @@ -37,14 +37,20 @@ static int collect_one_packet(void *obj,
> ProtobufCMessage *msg, struct cr_img *i
>  	struct sk_packet *pkt = obj;
> 
>  	pkt->entry = pb_msg(msg, SkPacketEntry);
> -	pkt->img_off = lseek(img_raw_fd(img), 0, SEEK_CUR);
> +
> +	pkt->data = xmalloc(pkt->entry->length);
> +	if (pkt->data ==NULL)
> +		return -1;
> +
>  	/*
>  	 * NOTE: packet must be added to the tail. Otherwise sequence
>  	 * will be broken.
>  	 */
>  	list_add_tail(&pkt->list, &packets_list);
> -	if (lseek(img_raw_fd(img), pkt->entry->length, SEEK_CUR) < 0) {
> -		pr_perror("Unable to change an image offset");
> +
> +	if (read_img_buf(img, pkt->data, pkt->entry->length) != 1) {
> +		xfree(pkt->data);
> +		pr_perror("Unable to read packet data");
>  		return -1;
>  	}
> 
> @@ -208,7 +214,6 @@ int restore_sk_queue(int fd, unsigned int peer_id)
> 
>  	list_for_each_entry_safe(pkt, tmp, &packets_list, list) {
>  		SkPacketEntry *entry = pkt->entry;
> -		char *buf;
> 
>  		if (entry->id_for != peer_id)
>  			continue;
> @@ -224,22 +229,8 @@ int restore_sk_queue(int fd, unsigned int peer_id)
>  		 * boundaries messages should be saved.
>  		 */
> 
> -		buf = xmalloc(entry->length);
> -		if (buf ==NULL)
> -			goto err;
> -
> -		if (lseek(img_raw_fd(img), pkt->img_off, SEEK_SET) == -1) {
> -			pr_perror("lseek() failed");
> -			xfree(buf);
> -			goto err;
> -		}
> -		if (read_img_buf(img, buf, entry->length) != 1) {
> -			xfree(buf);
> -			goto err;
> -		}
> -
> -		ret = write(fd, buf, entry->length);
> -		xfree(buf);
> +		ret = write(fd, pkt->data, entry->length);
> +		xfree(pkt->data);

Please, send the restore_sk_queue() rework as separate patch.

>  		if (ret < 0) {
>  			pr_perror("Failed to send packet");
>  			goto err;



More information about the CRIU mailing list