[CRIU] [PATCH 08/22] files: Move inet sockets into files image
Pavel Emelyanov
xemul at virtuozzo.com
Fri Jun 30 13:57:56 MSK 2017
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/cr-restore.c | 2 +-
criu/files.c | 3 +++
criu/include/image-desc.h | 2 +-
criu/include/sockets.h | 2 +-
criu/sk-inet.c | 12 ++++++------
images/fdinfo.proto | 2 ++
6 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 8b81de9..424b87b 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -236,7 +236,7 @@ static int crtools_prepare_shared(void)
return -1;
/* Connections are unlocked from criu */
- if (collect_inet_sockets())
+ if (!files_collected() && collect_image(&inet_sk_cinfo))
return -1;
if (collect_binfmt_misc())
diff --git a/criu/files.c b/criu/files.c
index 5d7e6c4..4cbe6ee 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1804,6 +1804,9 @@ static int collect_one_file(void *o, ProtobufCMessage *base, struct cr_img *i)
case FD_TYPES__REG:
ret = collect_one_file_entry(fe, fe->reg->id, &fe->reg->base, ®_file_cinfo);
break;
+ case FD_TYPES__INETSK:
+ ret = collect_one_file_entry(fe, fe->isk->id, &fe->isk->base, &inet_sk_cinfo);
+ break;
}
return ret;
diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h
index 41896c5..b2957b7 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_NS_FILES,
- CR_FD_INETSK,
CR_FD_UNIXSK,
CR_FD_PACKETSK,
CR_FD_NETLINK_SK,
@@ -106,6 +105,7 @@ enum {
CR_FD_FANOTIFY_MARK,
CR_FD_EVENTPOLL_TFD,
CR_FD_REG_FILES,
+ CR_FD_INETSK,
CR_FD_AUTOFS,
CR_FD_NS,
diff --git a/criu/include/sockets.h b/criu/include/sockets.h
index adea911..9881d5b 100644
--- a/criu/include/sockets.h
+++ b/criu/include/sockets.h
@@ -34,7 +34,7 @@ extern bool socket_test_collect_bit(unsigned int family, unsigned int proto);
extern int sk_collect_one(unsigned ino, int family, struct socket_desc *d, struct ns_id *ns);
struct ns_id;
extern int collect_sockets(struct ns_id *);
-extern int collect_inet_sockets(void);
+extern struct collect_image_info inet_sk_cinfo;
extern struct collect_image_info unix_sk_cinfo;
extern int fix_external_unix_sockets(void);
diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index 5077d35..0f55144 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -314,6 +314,7 @@ static bool needs_scope_id(uint32_t *src_addr)
static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int family)
{
struct inet_sk_desc *sk;
+ FileEntry fe = FILE_ENTRY__INIT;
InetSkEntry ie = INET_SK_ENTRY__INIT;
IpOptsEntry ipopts = IP_OPTS_ENTRY__INIT;
SkOptsEntry skopts = SK_OPTS_ENTRY__INIT;
@@ -431,7 +432,11 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
ie.state = sk->state;
- if (pb_write_one(img_from_set(glob_imgset, CR_FD_INETSK), &ie, PB_INET_SK))
+ fe.type = FD_TYPES__INETSK;
+ fe.id = ie.id;
+ fe.isk = &ie;
+
+ if (pb_write_one(img_from_set(glob_imgset, CR_FD_FILES), &fe, PB_FILE))
goto err;
err:
release_skopts(&skopts);
@@ -543,11 +548,6 @@ struct collect_image_info inet_sk_cinfo = {
.collect = collect_one_inetsk,
};
-int collect_inet_sockets(void)
-{
- return collect_image(&inet_sk_cinfo);
-}
-
static int inet_validate_address(InetSkEntry *ie)
{
if ((ie->family == AF_INET) &&
diff --git a/images/fdinfo.proto b/images/fdinfo.proto
index 6d62926..2dbe154 100644
--- a/images/fdinfo.proto
+++ b/images/fdinfo.proto
@@ -1,6 +1,7 @@
syntax = "proto2";
import "regfile.proto";
+import "sk-inet.proto";
enum fd_types {
UND = 0;
@@ -37,4 +38,5 @@ message file_entry {
required fd_types type = 1;
required uint32 id = 2;
optional reg_file_entry reg = 3;
+ optional inet_sk_entry isk = 4;
}
--
2.1.4
More information about the CRIU
mailing list