[5/5] tty: Move tty into files image

Submitted by Pavel Emelianov on July 19, 2017, 11:20 a.m.

Details

Message ID 7310997e-1a01-4f8b-b38d-d11d9b230164@virtuozzo.com
State Accepted
Series "Merge tty files into files image"
Headers show

Commit Message

Pavel Emelianov July 19, 2017, 11:20 a.m.
This completes merging files images into one.

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

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 74a1b9f..3249e86 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -289,7 +289,6 @@  static struct collect_image_info *cinfos_files[] = {
 
 /* These images are requered to restore namespaces */
 static struct collect_image_info *before_ns_cinfos[] = {
-	&tty_cinfo,
 	&tty_info_cinfo, /* Restore devpts content */
 	&tty_cdata,
 };
@@ -1790,6 +1789,8 @@  static int restore_task_with_children(void *_arg)
 		if (mount_proc())
 			goto err;
 
+		if (!files_collected() && collect_image(&tty_cinfo))
+			goto err;
 		if (collect_images(before_ns_cinfos, ARRAY_SIZE(before_ns_cinfos)))
 			goto err;
 
diff --git a/criu/files.c b/criu/files.c
index 667656a..20505b3 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1852,6 +1852,9 @@  static int collect_one_file(void *o, ProtobufCMessage *base, struct cr_img *i)
 	case FD_TYPES__PIPE:
 		ret = collect_one_file_entry(fe, fe->pipe->id, &fe->pipe->base, &pipe_cinfo);
 		break;
+	case FD_TYPES__TTY:
+		ret = collect_one_file_entry(fe, fe->tty->id, &fe->tty->base, &tty_cinfo);
+		break;
 	}
 
 	return ret;
diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h
index a28d5d0..408004c 100644
--- a/criu/include/image-desc.h
+++ b/criu/include/image-desc.h
@@ -58,7 +58,6 @@  enum {
 	CR_FD_SK_QUEUES,
 	CR_FD_PIPES_DATA,
 	CR_FD_FIFO_DATA,
-	CR_FD_TTY_FILES,
 	CR_FD_TTY_INFO,
 	CR_FD_TTY_DATA,
 	CR_FD_REMAP_FPATH,
@@ -106,6 +105,7 @@  enum {
 	CR_FD_UNIXSK,
 	CR_FD_FIFO,
 	CR_FD_PIPES,
+	CR_FD_TTY_FILES,
 
 	CR_FD_AUTOFS,
 	CR_FD_NS,
diff --git a/criu/tty.c b/criu/tty.c
index 0076348..5e90928 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1930,8 +1930,15 @@  static int dump_one_tty(int lfd, u32 id, const struct fd_parms *p)
 	if (!tty_test_and_set(e.tty_info_id, tty_bitmap))
 		ret = dump_tty_info(lfd, e.tty_info_id, p, driver, index);
 
-	if (!ret)
-		ret = pb_write_one(img_from_set(glob_imgset, CR_FD_TTY_FILES), &e, PB_TTY_FILE);
+	if (!ret) {
+		FileEntry fe = FILE_ENTRY__INIT;
+
+		fe.type = FD_TYPES__TTY;
+		fe.id = e.id;
+		fe.tty = &e;
+		ret = pb_write_one(img_from_set(glob_imgset, CR_FD_FILES), &fe, PB_FILE);
+	}
+
 	return ret;
 }
 
diff --git a/images/fdinfo.proto b/images/fdinfo.proto
index bcd5cba..3d4e507 100644
--- a/images/fdinfo.proto
+++ b/images/fdinfo.proto
@@ -15,6 +15,7 @@  import "ext-file.proto";
 import "sk-unix.proto";
 import "fifo.proto";
 import "pipe.proto";
+import "tty.proto";
 
 enum fd_types {
 	UND		= 0;
@@ -66,4 +67,5 @@  message file_entry {
 	optional unix_sk_entry		usk	= 16;
 	optional fifo_entry		fifo	= 17;
 	optional pipe_entry		pipe	= 18;
+	optional tty_file_entry		tty	= 19;
 }