[CRIU] [PATCH] crtools: add addr string to opts.

Ruslan Kuprieiev kupruser at gmail.com
Mon Aug 12 07:14:36 EDT 2013


On 12.08.2013 12:32, Pavel Emelyanov wrote:
> On 08/11/2013 10:02 PM, Ruslan Kuprieiev wrote:
>> On 09.08.2013 11:48, Pavel Emelyanov wrote:
>> Thank you for your explanations.
>> Here is one more try.
>> @@ -288,6 +285,14 @@ int main(int argc, char *argv[])
>>   		return -1;
>>   	}
>>   
>> +	/* Convert char *addr to sockaddr_in ps_addr if command != service */
> What if we introduce another command that would require some --address? Will
> we have to patch this place again?
>
>> +	if (opts.addr && strcmp(argv[optind], "service")) {
>> +		if (!inet_aton(opts.addr, &opts.ps_addr.sin_addr)) {
>> +			pr_perror("Bad address");
>> +			return -1;
>> +		}
>> +	}
>> +
>>   	if (optind >= argc)
>>   		goto usage;
>>   
And here is one more try.

-- 
Signed-off-by: Ruslan Kuprieiev kupruser at gmail.com

-------------- next part --------------
diff --git a/crtools.c b/crtools.c
index 51d188a..71c312f 100644
--- a/crtools.c
+++ b/crtools.c
@@ -235,10 +235,7 @@ int main(int argc, char *argv[])
 			opts.use_page_server = true;
 			break;
 		case 51:
-			if (!inet_aton(optarg, &opts.ps_addr.sin_addr)) {
-				pr_perror("Bad address");
-				return -1;
-			}
+			opts.addr = strdup(optarg);
 			break;
 		case 52:
 			opts.ps_addr.sin_port = htons(atoi(optarg));
@@ -291,6 +288,15 @@ int main(int argc, char *argv[])
 	if (optind >= argc)
 		goto usage;
 
+	/* Convert char *addr to sockaddr_in ps_addr if using page-server */
+	if ((!strcmp(argv[optind], "page-server") || opts.use_page_server)
+								&& opts.addr) {
+		if (!inet_aton(opts.addr, &opts.ps_addr.sin_addr)) {
+			pr_perror("Bad address");
+			return -1;
+		}
+	}
+
 	if (!strcmp(argv[optind], "dump")) {
 		if (!tree_id)
 			goto opt_pid_missing;
diff --git a/include/crtools.h b/include/crtools.h
index 81e89e1..da832f2 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -41,6 +41,7 @@ struct cr_options {
 	struct list_head	scripts;
 	bool			use_page_server;
 	struct sockaddr_in	ps_addr;
+	char			*addr;
 	bool			track_mem;
 	char			*img_parent;
 };

Signed-off-by: Ruslan Kuprieiev kupruser at gmail.com


More information about the CRIU mailing list