[CRIU] [PATCH 08/14] pstree: allocate fdt shared data

Pavel Emelyanov xemul at parallels.com
Fri Jan 11 05:45:26 EST 2013


On 01/11/2013 01:22 PM, Andrey Vagin wrote:
> fdt shared data contains PID of process, which will restore file
> descriptors and a futex for synchronization.
> 
> A process with mimimal pid restores file descriptors.
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  include/crtools.h |  9 +++++++++
>  include/pstree.h  |  8 ++++++++
>  pstree.c          | 34 ++++++++++++++++++++++++++++++++++
>  3 files changed, 51 insertions(+)
> 
> diff --git a/include/crtools.h b/include/crtools.h
> index a51998d..0afa2a1 100644
> --- a/include/crtools.h
> +++ b/include/crtools.h
> @@ -8,6 +8,7 @@
>  #include "list.h"
>  #include "util.h"
>  #include "image.h"
> +#include "lock.h"
>  
>  #include "../protobuf/vma.pb-c.h"
>  
> @@ -229,6 +230,12 @@ struct vma_area {
>  #define vma_area_is(vma_area, s)	vma_entry_is(&((vma_area)->vma), s)
>  #define vma_area_len(vma_area)		vma_entry_len(&((vma_area)->vma))
>  
> +struct fdt {
> +	futex_t			fdt_lock;
> +	int			nr;
> +	pid_t			pid;

With such descriptive names comments describing each are required.

> +};
> +
>  struct rst_info {
>  	struct list_head	fds;
>  	struct list_head	eventpoll;
> @@ -236,6 +243,8 @@ struct rst_info {
>  
>  	void			*premmapped_addr;
>  	unsigned long		premmapped_len;
> +
> +	struct fdt		*fdt;

So this will be NULL for those, not having its fdt shared. Worth making
it non NULL always? If no -- better name would be better.

>  };
>  
>  static inline int in_vma_area(struct vma_area *vma, unsigned long addr)
> diff --git a/include/pstree.h b/include/pstree.h
> index 7e1a40c..f53d1f6 100644
> --- a/include/pstree.h
> +++ b/include/pstree.h
> @@ -46,6 +46,14 @@ struct pstree_item {
>  	struct rst_info		rst[0];
>  };
>  
> +static inline int shared_fdtable(struct pstree_item *item) {
> +	return (item->parent && item->parent->state != TASK_HELPER &&
> +		item->ids &&
> +		item->parent->ids &&
> +		item->ids->files_id &&
> +		item->ids->files_id == item->parent->ids->files_id);

How can be parent->ids == NULL? Same for item->ids?

> +}
> +
>  extern void free_pstree(struct pstree_item *root_item);
>  extern struct pstree_item *__alloc_pstree_item(bool rst);
>  #define alloc_pstree_item() __alloc_pstree_item(false)


More information about the CRIU mailing list