[CRIU] [PATCH 06/18] fifo: Generate unique ID for satellite regfile entry

Pavel Emelyanov xemul at virtuozzo.com
Mon Jul 10 12:39:05 MSK 2017


The plan is to have all file entries have unique ID. Fifo
generates a reg file entry to reuse the whole reg-files
c/r-ing engine (ghosts, open-by-path, etc.) and right now
ID for this entry is the same as for fifo entry.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/fifo.c       | 14 +++++++++++---
 images/fifo.proto |  1 +
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/criu/fifo.c b/criu/fifo.c
index d0728e1..a269343 100644
--- a/criu/fifo.c
+++ b/criu/fifo.c
@@ -8,6 +8,7 @@
 #include "image.h"
 #include "files.h"
 #include "files-reg.h"
+#include "file-ids.h"
 #include "pipes.h"
 
 #include "fifo.h"
@@ -43,13 +44,16 @@ static int dump_one_fifo(int lfd, u32 id, const struct fd_parms *p)
 	struct cr_img *img = img_from_set(glob_imgset, CR_FD_FILES);
 	FileEntry fe = FILE_ENTRY__INIT;
 	FifoEntry e = FIFO_ENTRY__INIT;
+	u32 rf_id;
+
+	fd_id_generate_special(NULL, &rf_id);
 
 	/*
 	 * It's a trick here, we use regular files dumping
 	 * code to save path to a fifo, then we reuse it
 	 * on restore.
 	 */
-	if (dump_one_reg_file(lfd, id, p))
+	if (dump_one_reg_file(lfd, rf_id, p))
 		return -1;
 
 	pr_info("Dumping fifo %d with id %#x pipe_id %#x\n",
@@ -57,6 +61,8 @@ static int dump_one_fifo(int lfd, u32 id, const struct fd_parms *p)
 
 	e.id		= id;
 	e.pipe_id	= pipe_id(p);
+	e.has_regf_id	= true;
+	e.regf_id	= rf_id;
 
 	fe.type = FD_TYPES__FIFO;
 	fe.id = e.id;
@@ -116,8 +122,10 @@ static int open_fifo_fd(struct file_desc *d, int *new_fd)
 	struct file_desc *reg_d;
 	int fd;
 
-	reg_d = find_file_desc_raw(FD_TYPES__REG, info->fe->id);
-	BUG_ON(!reg_d);
+	reg_d = collect_special_file(info->fe->has_regf_id ?
+			info->fe->regf_id : info->fe->id);
+	if (!reg_d)
+		return -1;
 
 	fd = open_path(reg_d, do_open_fifo, info);
 	if (fd < 0)
diff --git a/images/fifo.proto b/images/fifo.proto
index 9d5b953..f5b3283 100644
--- a/images/fifo.proto
+++ b/images/fifo.proto
@@ -3,4 +3,5 @@ syntax = "proto2";
 message fifo_entry {
 	required uint32		id		= 1;
 	required uint32		pipe_id		= 2;
+	optional uint32		regf_id		= 3;
 }
-- 
2.1.4



More information about the CRIU mailing list