[CRIU] [PATCH 22/22] files: Move pipes into files image

Pavel Emelyanov xemul at virtuozzo.com
Fri Jun 30 14:02:54 MSK 2017


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-restore.c         | 2 +-
 criu/files.c              | 3 +++
 criu/include/image-desc.h | 2 +-
 criu/pipes.c              | 7 ++++++-
 images/fdinfo.proto       | 2 ++
 5 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 5535a4d..677bbc4 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -261,7 +261,6 @@ static int crtools_prepare_shared(void)
  */
 
 static struct collect_image_info *cinfos[] = {
-	&pipe_cinfo,
 	&file_locks_cinfo,
 	&pipe_data_cinfo,
 	&fifo_data_cinfo,
@@ -271,6 +270,7 @@ static struct collect_image_info *cinfos[] = {
 static struct collect_image_info *cinfos_files[] = {
 	&unix_sk_cinfo,
 	&fifo_cinfo,
+	&pipe_cinfo,
 	&nsfile_cinfo,
 	&packet_sk_cinfo,
 	&netlink_sk_cinfo,
diff --git a/criu/files.c b/criu/files.c
index 76a2ddc..5953e96 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1847,6 +1847,9 @@ static int collect_one_file(void *o, ProtobufCMessage *base, struct cr_img *i)
 	case FD_TYPES__FIFO:
 		ret = collect_one_file_entry(fe, fe->fifo->id, &fe->fifo->base, &fifo_cinfo);
 		break;
+	case FD_TYPES__PIPE:
+		ret = collect_one_file_entry(fe, fe->pipe->id, &fe->pipe->base, &pipe_cinfo);
+		break;
 	}
 
 	return ret;
diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h
index 0df3592..a28d5d0 100644
--- a/criu/include/image-desc.h
+++ b/criu/include/image-desc.h
@@ -56,7 +56,6 @@ enum {
 	_CR_FD_GLOB_FROM,
 	CR_FD_FILES,
 	CR_FD_SK_QUEUES,
-	CR_FD_PIPES,
 	CR_FD_PIPES_DATA,
 	CR_FD_FIFO_DATA,
 	CR_FD_TTY_FILES,
@@ -106,6 +105,7 @@ enum {
 	CR_FD_EXT_FILES,
 	CR_FD_UNIXSK,
 	CR_FD_FIFO,
+	CR_FD_PIPES,
 
 	CR_FD_AUTOFS,
 	CR_FD_NS,
diff --git a/criu/pipes.c b/criu/pipes.c
index cb150f3..f1a66bf 100644
--- a/criu/pipes.c
+++ b/criu/pipes.c
@@ -487,6 +487,7 @@ static struct pipe_data_dump pd_pipes = { .img_type = CR_FD_PIPES_DATA, };
 
 static int dump_one_pipe(int lfd, u32 id, const struct fd_parms *p)
 {
+	FileEntry fe = FILE_ENTRY__INIT;
 	PipeEntry pe = PIPE_ENTRY__INIT;
 
 	pr_info("Dumping pipe %d with id %#x pipe_id %#x\n",
@@ -502,7 +503,11 @@ static int dump_one_pipe(int lfd, u32 id, const struct fd_parms *p)
 	pe.flags	= p->flags & ~O_DIRECT;
 	pe.fown		= (FownEntry *)&p->fown;
 
-	if (pb_write_one(img_from_set(glob_imgset, CR_FD_PIPES), &pe, PB_PIPE))
+	fe.type = FD_TYPES__PIPE;
+	fe.id = pe.id;
+	fe.pipe = &pe;
+
+	if (pb_write_one(img_from_set(glob_imgset, CR_FD_FILES), &fe, PB_FILE))
 		return -1;
 
 	return dump_one_pipe_data(&pd_pipes, lfd, p);
diff --git a/images/fdinfo.proto b/images/fdinfo.proto
index 53bb5fc..bcd5cba 100644
--- a/images/fdinfo.proto
+++ b/images/fdinfo.proto
@@ -14,6 +14,7 @@ import "fsnotify.proto";
 import "ext-file.proto";
 import "sk-unix.proto";
 import "fifo.proto";
+import "pipe.proto";
 
 enum fd_types {
 	UND		= 0;
@@ -64,4 +65,5 @@ message file_entry {
 	optional ext_file_entry		ext	= 15;
 	optional unix_sk_entry		usk	= 16;
 	optional fifo_entry		fifo	= 17;
+	optional pipe_entry		pipe	= 18;
 }
-- 
2.1.4



More information about the CRIU mailing list