2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-01 06:45:35 +00:00

crtools: link pstree_item-s in a tree (v3)

because they describes a process TREE.

It's usefull, when we dump tasks from another pid namespace,
because a real pid is got from parasite. In previous version
we need to update pid in two places one is in a pstree_item and
one is in a children array.

A process tree will be necessery to restore sid and pgid,
because we should add fake tasks in a tree. For example if
a sesion leader is absent.

v2: fix rollback actions
v3: fix comments from Pavel Emelyanov
    * add macros for_each_pstree_item
    * and a few bugs

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin
2012-05-31 14:50:00 +04:00
committed by Pavel Emelyanov
parent ced64e22c0
commit cf63c1d9e8
5 changed files with 196 additions and 158 deletions

View File

@@ -3,13 +3,12 @@
#include <sys/types.h>
#include "list.h"
#include "types.h"
#include "list.h"
#include "util.h"
#include "image.h"
extern void free_pstree(struct list_head *pstree_list);
#define CR_FD_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)
#define CR_FD_PERM_DUMP (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
@@ -180,16 +179,21 @@ struct pstree_item {
struct list_head list;
pid_t pid; /* leader pid */
struct pstree_item *parent;
struct list_head children; /* array of children */
pid_t pgid;
pid_t sid;
int state; /* TASK_XXX constants */
int nr_children; /* number of children */
int nr_threads; /* number of threads */
u32 *threads; /* array of threads */
u32 *children; /* array of children */
struct rst_info *rst;
};
extern struct pstree_item *alloc_pstree_item(void);
extern struct pstree_item *pstree_item_next(struct pstree_item *item);
#define for_each_pstree_item(pi) \
for (pi = root_item; pi != NULL; pi = pstree_item_next(pi))
static inline int in_vma_area(struct vma_area *vma, unsigned long addr)
{
return addr >= (unsigned long)vma->vma.start &&