[CRIU] [PATCH 09/18] file: Find descs by ID only (v2)

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


Actually all file-s we dump have unique IDs, regardless of
their types. This fact will be used to reduce complexity
of the SCM code -- instead of keeping TYPE:ID pair it'll
save only the ID.

Siad that -- we will need the way to lookup desc by ID only.

v2: Older images had fifo-s and tty-s having matching IDs
    with respective reg-file entries

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/files.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/criu/files.c b/criu/files.c
index affdac0..a0e40f1 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -101,7 +101,15 @@ struct file_desc *find_file_desc_raw(int type, u32 id)
 
 	chain = &file_desc_hash[id % FDESC_HASH_SIZE];
 	hlist_for_each_entry(d, chain, hash)
-		if (d->ops->type == type && d->id == id)
+		if ((d->id == id) &&
+				(d->ops->type == type || type == FD_TYPES__UND))
+			/*
+			 * Warning -- old CRIU might generate matching IDs
+			 * for different file types! So any code that uses
+			 * FD_TYPES__UND for fdesc search MUST make sure it's
+			 * dealing with the merged files images where all
+			 * descs are forced to have different IDs.
+			 */
 			return d;
 
 	return NULL;
-- 
2.1.4



More information about the CRIU mailing list