[CRIU] [PATCH] service: add support for the --external option

Andrey Vagin avagin at openvz.org
Wed Jan 13 16:18:47 PST 2016


From: Andrew Vagin <avagin at virtuozzo.com>

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 cr-service.c         |  4 ++++
 crtools.c            | 24 +++++++++++++++---------
 include/cr_options.h |  2 ++
 protobuf/rpc.proto   |  1 +
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/cr-service.c b/cr-service.c
index 1f903b6..00dc17d 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -381,6 +381,10 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 			goto err;
 	}
 
+	for (i = 0; i < req->n_external; i++)
+		if (add_external(req->external[i]))
+			goto err;
+
 	for (i = 0; i < req->n_cg_root; i++) {
 		if (new_cg_root_add(req->cg_root[i]->ctrl,
 					req->cg_root[i]->path))
diff --git a/crtools.c b/crtools.c
index 7e69239..d5cb20e 100644
--- a/crtools.c
+++ b/crtools.c
@@ -193,6 +193,19 @@ static size_t parse_size(char *optarg)
 	return (size_t)atol(optarg);
 }
 
+int add_external(char *key)
+{
+	struct external *ext;
+
+	ext = xmalloc(sizeof(*ext));
+	if (!ext)
+		return -1;
+	ext->id = key;
+	list_add(&ext->node, &opts.external);
+
+	return 0;
+}
+
 int main(int argc, char *argv[], char *envp[])
 {
 	pid_t pid = 0, tree_id = 0;
@@ -526,15 +539,8 @@ int main(int argc, char *argv[], char *envp[])
 			}
 			break;
 		case 1073:
-			{
-				struct external *ext;
-
-				ext = xmalloc(sizeof(*ext));
-				if (!ext)
-					return 1;
-				ext->id = optarg;
-				list_add(&ext->node, &opts.external);
-			}
+			if (add_external(optarg))
+				return 1;
 			break;
 		case 'V':
 			pr_msg("Version: %s\n", CRIU_VERSION);
diff --git a/include/cr_options.h b/include/cr_options.h
index 3f14b43..5c0e633 100644
--- a/include/cr_options.h
+++ b/include/cr_options.h
@@ -112,4 +112,6 @@ extern struct cr_options opts;
 
 extern void init_opts(void);
 
+extern int add_external(char *key);
+
 #endif /* __CR_OPTIONS_H__ */
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index 30235a0..4f6ed8d 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -88,6 +88,7 @@ message criu_opts {
 	optional criu_cg_mode		manage_cgroups_mode = 34;
 	optional uint32			ghost_limit	= 35 [default = 0x100000];
 	repeated string			irmap_scan_paths = 36;
+	repeated string			external	= 37;
 }
 
 message criu_dump_resp {
-- 
2.4.3



More information about the CRIU mailing list