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

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Thu Jan 7 08:10:39 PST 2016


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 {
+	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:



More information about the CRIU mailing list