[CRIU] [PATCH cr 5/6] pstree: allocate rst parts from a shared region

Andrey Vagin avagin at openvz.org
Tue Oct 2 10:07:21 EDT 2012


The next patch will add a futex, which will be used for restoring
shared fd tables.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/pstree.h |    2 +-
 pstree.c         |    8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/pstree.h b/include/pstree.h
index 0790b49..2da7176 100644
--- a/include/pstree.h
+++ b/include/pstree.h
@@ -20,7 +20,7 @@ struct pstree_item {
 	int			state;		/* TASK_XXX constants */
 	int			nr_threads;	/* number of threads */
 	struct pid		*threads;	/* array of threads */
-	struct rst_info		rst[0];
+	struct rst_info		*rst;
 };
 
 extern void free_pstree(struct pstree_item *root_item);
diff --git a/pstree.c b/pstree.c
index 8df5a63..1672b26 100644
--- a/pstree.c
+++ b/pstree.c
@@ -33,10 +33,16 @@ struct pstree_item *__alloc_pstree_item(bool rst)
 {
 	struct pstree_item *item;
 
-	item = xzalloc(sizeof(*item) + (rst ? sizeof(item->rst[0]) : 0));
+	item = xzalloc(sizeof(*item));
 	if (!item)
 		return NULL;
 
+	if (rst) {
+		item->rst = shmalloc(sizeof(item->rst[0]));
+		if (!item->rst)
+			return NULL;
+	}
+
 	INIT_LIST_HEAD(&item->children);
 	item->threads = NULL;
 	item->nr_threads = 0;
-- 
1.7.1



More information about the CRIU mailing list