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

Ruslan Kuprieiev kupruser at gmail.com
Thu Aug 8 17:40:53 EDT 2013


On 08.08.2013 23:45, Pavel Emelyanov wrote:
> On 08/08/2013 09:34 PM, Ruslan Kuprieiev wrote:
>> On 08.08.2013 19:53, Pavel Emelyanov wrote:
>>> On 08/08/2013 08:44 PM, Ruslan Kuprieiev wrote:
>>>> Hello!
>>>>
>>>> Added char * addr field to struct cr_options. It will be used as socket
>>>> address in cr_service(). addr is properly converted into ps_addr if
>>>> "page-server" command is set.
>>>>
>>> You obviously didn't check this change, as ps_addr thing in your
>>> patch if only initialized for page-server action, while can also
>>> be used on dump --page-server combination.
>>>
>>> Thanks,
>>> Pavel
>> Sorry.
>> Here is another one.
>>
> Another? Or one more? In the former case it's not tested either.
>
>> @@ -235,9 +235,14 @@ 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;
>> +			if (opts.use_page_server) {
> First of all, options may go in any order. And this
>
> dump --address 127.0.0.1 --page-server
>
> should work.
>
> But that's minor. The major thing is that -- the page-server action now lacks
> char -> sockaddr_in conversion.
>
>> +				if (!inet_aton(optarg,
>> +						&opts.ps_addr.sin_addr)) {
>> +					pr_perror("Bad address");
>> +					return -1;
>> +				}
>> +			} else {
>> +				opts.addr = strdup(optarg);
>>   			}
>>   			break;
>>   		case 52:
I guess, i understood what should i do.
Here is one more version.
As for me, it should work, but when i`m trying to dump program with:

dump --address 127.0.0.1 --page-server

i get an error, that says "Connection refused".
Am i doing something wrong again?

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

-------------- next part --------------
diff --git a/crtools.c b/crtools.c
index 51d188a..944cfef 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));
@@ -288,6 +285,17 @@ int main(int argc, char *argv[])
 		return -1;
 	}
 
+	/*
+	 * if command != "service", we state, that char *opts.addr
+	 * is address of page server, so we convert it to sockaddr_in ps_addr
+	 */
+	if (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;
 
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