[CRIU] [PATCH v8 09/15] cr-restore: new list of ns shared objects introduced

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Wed Mar 16 06:17:46 PDT 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>
---
 criu/cr-restore.c |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 9d74959..cdc2d00 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -180,6 +180,39 @@ static struct collect_image_info *cinfos[] = {
 	&file_locks_cinfo,
 };
 
+struct ns_shared_cb {
+	struct list_head list;
+	int (*actor)(void *data);
+	void *data;
+};
+
+struct list_head ns_shared_cbs = LIST_HEAD_INIT(ns_shared_cbs);
+
+int add_ns_shared_cb(int (*actor)(void *data), void *data)
+{
+	struct ns_shared_cb *cb;
+
+	cb = xmalloc(sizeof(*cb));
+	if (!cb)
+		return -1;
+
+	cb->actor = actor;
+	cb->data = data;
+	list_add(&cb->list, &ns_shared_cbs);
+	return 0;
+}
+
+static int prepare_ns_shared(void)
+{
+	struct ns_shared_cb *o;
+
+	list_for_each_entry(o, &ns_shared_cbs, list) {
+		if (o->actor(o->data))
+			return -1;
+	}
+	return 0;
+}
+
 static int root_prepare_shared(void)
 {
 	int ret = 0, i;
@@ -249,6 +282,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