[11/22] files: Move netlink sock into files image

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

Details

Message ID 415fddeb-3f23-ced8-cc7c-5cd5011882ec@virtuozzo.com
State Accepted
Series "Merge images with different files into one"
Headers show

Commit Message

Pavel Emelianov June 30, 2017, 10:59 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/sk-netlink.c         | 7 ++++++-
 images/fdinfo.proto       | 2 ++
 5 files changed, 13 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index dce34ab..653b8c0 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -264,7 +264,6 @@  static struct collect_image_info *cinfos[] = {
 	&pipe_cinfo,
 	&fifo_cinfo,
 	&unix_sk_cinfo,
-	&netlink_sk_cinfo,
 	&eventfd_cinfo,
 	&epoll_cinfo,
 	&epoll_tfd_cinfo,
@@ -285,6 +284,7 @@  static struct collect_image_info *cinfos[] = {
 static struct collect_image_info *cinfos_files[] = {
 	&nsfile_cinfo,
 	&packet_sk_cinfo,
+	&netlink_sk_cinfo,
 };
 
 /* These images are requered to restore namespaces */
diff --git a/criu/files.c b/criu/files.c
index fa05448..aaca0d1 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1814,6 +1814,9 @@  static int collect_one_file(void *o, ProtobufCMessage *base, struct cr_img *i)
 	case FD_TYPES__PACKETSK:
 		ret = collect_one_file_entry(fe, fe->psk->id, &fe->psk->base, &packet_sk_cinfo);
 		break;
+	case FD_TYPES__NETLINKSK:
+		ret = collect_one_file_entry(fe, fe->nlsk->id, &fe->nlsk->base, &netlink_sk_cinfo);
+		break;
 	}
 
 	return ret;
diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h
index 1a1edff..3dad32a 100644
--- a/criu/include/image-desc.h
+++ b/criu/include/image-desc.h
@@ -58,7 +58,6 @@  enum {
 	CR_FD_SK_QUEUES,
 	CR_FD_EXT_FILES,
 	CR_FD_UNIXSK,
-	CR_FD_NETLINK_SK,
 	CR_FD_PIPES,
 	CR_FD_PIPES_DATA,
 	CR_FD_FIFO,
@@ -106,6 +105,7 @@  enum {
 	CR_FD_INETSK,
 	CR_FD_NS_FILES,
 	CR_FD_PACKETSK,
+	CR_FD_NETLINK_SK,
 
 	CR_FD_AUTOFS,
 	CR_FD_NS,
diff --git a/criu/sk-netlink.c b/criu/sk-netlink.c
index 44982a1..2da80c9 100644
--- a/criu/sk-netlink.c
+++ b/criu/sk-netlink.c
@@ -79,6 +79,7 @@  static bool can_dump_netlink_sk(int lfd)
 static int dump_one_netlink_fd(int lfd, u32 id, const struct fd_parms *p)
 {
 	struct netlink_sk_desc *sk;
+	FileEntry fe = FILE_ENTRY__INIT;
 	NetlinkSkEntry ne = NETLINK_SK_ENTRY__INIT;
 	SkOptsEntry skopts = SK_OPTS_ENTRY__INIT;
 
@@ -149,7 +150,11 @@  static int dump_one_netlink_fd(int lfd, u32 id, const struct fd_parms *p)
 	if (dump_socket_opts(lfd, &skopts))
 		goto err;
 
-	if (pb_write_one(img_from_set(glob_imgset, CR_FD_NETLINK_SK), &ne, PB_NETLINK_SK))
+	fe.type = FD_TYPES__NETLINKSK;
+	fe.id = ne.id;
+	fe.nlsk = &ne;
+
+	if (pb_write_one(img_from_set(glob_imgset, CR_FD_FILES), &fe, PB_FILE))
 		goto err;
 
 	return 0;
diff --git a/images/fdinfo.proto b/images/fdinfo.proto
index 9ebd3ba..cbfb3b7 100644
--- a/images/fdinfo.proto
+++ b/images/fdinfo.proto
@@ -4,6 +4,7 @@  import "regfile.proto";
 import "sk-inet.proto";
 import "ns.proto";
 import "packet-sock.proto";
+import "sk-netlink.proto";
 
 enum fd_types {
 	UND		= 0;
@@ -43,4 +44,5 @@  message file_entry {
 	optional inet_sk_entry		isk	= 4;
 	optional ns_file_entry		nsf	= 5;
 	optional packet_sock_entry	psk	= 6;
+	optional netlink_sk_entry	nlsk	= 7;
 }