[CRIU] [PATCH] crtools: image-{cache, proxy} requires address/port

Radostin Stoyanov rstoyanov1 at gmail.com
Fri Feb 16 21:11:32 MSK 2018


Show error message when image-{cache,proxy} is called without --port
and image-proxy without --address argument.

Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
---
 criu/crtools.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/criu/crtools.c b/criu/crtools.c
index dffae5c8..1fe7aabf 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -1043,11 +1043,21 @@ int main(int argc, char *argv[], char *envp[])
 	if (!strcmp(argv[optind], "page-server"))
 		return cr_page_server(opts.daemon_mode, false, -1) != 0;
 
-	if (!strcmp(argv[optind], "image-cache"))
+	if (!strcmp(argv[optind], "image-cache")) {
+		if (!opts.port)
+			goto opt_port_missing;
 		return image_cache(opts.daemon_mode, DEFAULT_CACHE_SOCKET, opts.port);
+	}
 
-	if (!strcmp(argv[optind], "image-proxy"))
+	if (!strcmp(argv[optind], "image-proxy")) {
+		if (!opts.addr) {
+			pr_msg("Error: address not specified\n");
+			return 1;
+		}
+		if (!opts.port)
+			goto opt_port_missing;
 		return image_proxy(opts.daemon_mode, DEFAULT_PROXY_SOCKET, opts.addr, opts.port);
+	}
 
 	if (!strcmp(argv[optind], "service"))
 		return cr_service(opts.daemon_mode);
@@ -1253,6 +1263,10 @@ usage:
 
 	return 0;
 
+opt_port_missing:
+	pr_msg("Error: port not specified\n");
+	return 1;
+
 opt_pid_missing:
 	pr_msg("Error: pid not specified\n");
 	return 1;
-- 
2.14.3



More information about the CRIU mailing list