[CRIU] [PATCH v4 14/17] cr-restore: new list of ns shared objects introduced

Stanislav Kinsburskiy skinsbursky at odin.com
Tue Jan 19 07:10:35 PST 2016



19.01.2016 16:08, Pavel Emelyanov пишет:
> On 01/07/2016 07:10 PM, Stanislav Kinsburskiy wrote:
>> Autofs restore needs to create some shared data structures to be able to pass
>> data to actual autofs master.
>> But on mount restore stage shared data is not configured yet.
>> This list of objects and their actors is processed after all mounts and shared
>> data are restored to let autofs to create the objects.
>>
>> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
>> ---
>>   cr-restore.c |   37 +++++++++++++++++++++++++++++++++++++
>>   1 file changed, 37 insertions(+)
>>
>> diff --git a/cr-restore.c b/cr-restore.c
>> index ea83b44..90b3c4c 100644
>> --- a/cr-restore.c
>> +++ b/cr-restore.c
>> @@ -181,6 +181,39 @@ static struct collect_image_info *cinfos[] = {
>>   	&file_locks_cinfo,
>>   };
>>   
>> +struct shared_ns_object {
> Strange name :)

Agreed. I'm not good in inventing names, so ready to accept any better.

>
> Try to move tty_setup_slavery() and resolve_unix_peers() onto this.

Let's crate another task for this? It doesn't really related to subj, 
and looks like an optimization.

>
>> +	struct list_head list;
>> +	int (*actor)(void *data);
>> +	void *data;
>> +};
>> +
>> +struct list_head shared_ns_objects = LIST_HEAD_INIT(shared_ns_objects);
>> +
>> +int add_shared_ns_obj(int (*actor)(void *data), void *data)
>> +{
>> +	struct shared_ns_object *obj;
>> +
>> +	obj = xmalloc(sizeof(*obj));
>> +	if (!obj)
>> +		return -1;
>> +
>> +	obj->actor = actor;
>> +	obj->data = data;
>> +	list_add(&obj->list, &shared_ns_objects);
>> +	return 0;
>> +}
>> +
>> +static int prepare_ns_shared(void)
>> +{
>> +	struct shared_ns_object *o;
>> +
>> +	list_for_each_entry(o, &shared_ns_objects, list) {
>> +		if (o->actor(o->data))
>> +			return -1;
>> +	}
>> +	return 0;
>> +}
>> +
>>   static int root_prepare_shared(void)
>>   {
>>   	int ret = 0, i;
>> @@ -250,6 +283,10 @@ static int root_prepare_shared(void)
>>   	if (ret)
>>   		goto err;
>>   
>> +	ret = prepare_ns_shared();
>> +	if (ret)
>> +		goto err;
>> +
>>   	show_saved_shmems();
>>   	show_saved_files();
>>   err:
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU at openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>> .
>>



More information about the CRIU mailing list