[09/22] files: Move ns files into files image

Submitted by Pavel Emelianov on June 30, 2017, 10:58 a.m.

Details

Message ID 6c954ac8-88dd-1540-7186-d1bd4c462ee2@virtuozzo.com
State Accepted
Series "Merge images with different files into one"
Headers show

Commit Message

Pavel Emelianov June 30, 2017, 10:58 a.m.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/cr-restore.c         |  2 +-
 criu/files.c              |  3 +++
 criu/include/image-desc.h |  2 +-
 criu/namespaces.c         | 10 ++++++++--
 images/fdinfo.proto       |  2 ++
 5 files changed, 15 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 424b87b..9e450e0 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[] = {
-	&nsfile_cinfo,
 	&pipe_cinfo,
 	&fifo_cinfo,
 	&unix_sk_cinfo,
@@ -285,6 +284,7 @@  static struct collect_image_info *cinfos[] = {
 };
 
 static struct collect_image_info *cinfos_files[] = {
+	&nsfile_cinfo,
 };
 
 /* These images are requered to restore namespaces */
diff --git a/criu/files.c b/criu/files.c
index 4cbe6ee..77af986 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1807,6 +1807,9 @@  static int collect_one_file(void *o, ProtobufCMessage *base, struct cr_img *i)
 	case FD_TYPES__INETSK:
 		ret = collect_one_file_entry(fe, fe->isk->id, &fe->isk->base, &inet_sk_cinfo);
 		break;
+	case FD_TYPES__NS:
+		ret = collect_one_file_entry(fe, fe->nsf->id, &fe->nsf->base, &nsfile_cinfo);
+		break;
 	}
 
 	return ret;
diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h
index b2957b7..ed70adb 100644
--- a/criu/include/image-desc.h
+++ b/criu/include/image-desc.h
@@ -57,7 +57,6 @@  enum {
 	CR_FD_FILES,
 	CR_FD_SK_QUEUES,
 	CR_FD_EXT_FILES,
-	CR_FD_NS_FILES,
 	CR_FD_UNIXSK,
 	CR_FD_PACKETSK,
 	CR_FD_NETLINK_SK,
@@ -106,6 +105,7 @@  enum {
 	CR_FD_EVENTPOLL_TFD,
 	CR_FD_REG_FILES,
 	CR_FD_INETSK,
+	CR_FD_NS_FILES,
 
 	CR_FD_AUTOFS,
 	CR_FD_NS,
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 15de9c5..100a631 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -499,7 +499,8 @@  static unsigned int get_ns_id(int pid, struct ns_desc *nd, protobuf_c_boolean *s
 
 int dump_one_ns_file(int lfd, u32 id, const struct fd_parms *p)
 {
-	struct cr_img *img = img_from_set(glob_imgset, CR_FD_NS_FILES);
+	struct cr_img *img;
+	FileEntry fe = FILE_ENTRY__INIT;
 	NsFileEntry nfe = NS_FILE_ENTRY__INIT;
 	struct fd_link *link = p->link;
 	struct ns_id *nsid;
@@ -515,7 +516,12 @@  int dump_one_ns_file(int lfd, u32 id, const struct fd_parms *p)
 	nfe.ns_cflag	= link->ns_d->cflag;
 	nfe.flags	= p->flags;
 
-	return pb_write_one(img, &nfe, PB_NS_FILE);
+	fe.type = FD_TYPES__NS;
+	fe.id = nfe.id;
+	fe.nsf = &nfe;
+
+	img = img_from_set(glob_imgset, CR_FD_FILES);
+	return pb_write_one(img, &fe, PB_FILE);
 }
 
 static UsernsEntry *dup_userns_entry(UsernsEntry *orig)
diff --git a/images/fdinfo.proto b/images/fdinfo.proto
index 2dbe154..8560cc4 100644
--- a/images/fdinfo.proto
+++ b/images/fdinfo.proto
@@ -2,6 +2,7 @@  syntax = "proto2";
 
 import "regfile.proto";
 import "sk-inet.proto";
+import "ns.proto";
 
 enum fd_types {
 	UND		= 0;
@@ -39,4 +40,5 @@  message file_entry {
 	required uint32			id	= 2;
 	optional reg_file_entry		reg	= 3;
 	optional inet_sk_entry		isk	= 4;
+	optional ns_file_entry		nsf	= 5;
 }