crtools: image-{cache, proxy} requires address/port

Submitted by Radostin Stoyanov on Feb. 16, 2018, 6:11 p.m.

Details

Message ID 20180216181132.4344-1-rstoyanov1@gmail.com
State Accepted
Series "crtools: image-{cache, proxy} requires address/port"
Commit 08d476e7ef55f3aefd9ad0a0732e887a0a2e959a
Headers show

Commit Message

Radostin Stoyanov Feb. 16, 2018, 6:11 p.m.
Show error message when image-{cache,proxy} is called without --port
and image-proxy without --address argument.

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

Patch hide | download patch | download mbox

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;

Comments

Andrey Vagin Feb. 19, 2018, 5:48 p.m.
Applied, thanks!

On Fri, Feb 16, 2018 at 06:11:32PM +0000, Radostin Stoyanov wrote:
> Show error message when image-{cache,proxy} is called without --port
> and image-proxy without --address argument.
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@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
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu