[CRIU] [PATCH 5/6] files: Add c/r for /proc/$pid/ns/$ids references

Pavel Emelyanov xemul at parallels.com
Tue May 14 16:47:32 EDT 2013


On 05/13/2013 07:39 PM, Cyrill Gorcunov wrote:
> 
> In this commit we implement c/r for files which have opened
> /proc/$pid/ns/$ids entries.
> 
> The idea is rather simple one
> 
> Checkpoint
> ==========
> 
> - Check if the file name is the one of known to be ns ref
> - If match then use generate_ns_id helper to generate namespace
>   ids (note if the ids came from nested namespace we issue error
>   out because it's not yet supported by criu)
> - Write protobuf entry
> 
> Restore
> =======
> 
> - Read all ns entries from the image
> - When criu tries to open one we lookup over process
>   tree to figure out which PID should be used in path
>   and then just open it.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  cr-restore.c         |   3 ++
>  files.c              |   5 +-
>  include/files.h      |   2 +
>  include/namespaces.h |   3 ++
>  namespaces.c         | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 146 insertions(+), 3 deletions(-)
> 
> +	switch (entry->d->type) {
> +	case NS_TYPES__NET:
> +	case NS_TYPES__UTS:
> +	case NS_TYPES__IPC:
> +	case NS_TYPES__PID:
> +	case NS_TYPES__MNT:
> +		break;
> +	default:

entry->d points somewhere into the ns_desc_array. What coincidence of circumstances
can lead to this default: case to occur?

> +		pr_err("Namespace `%s' referred by fd %d "
> +		       "(pid %d) is unsupported\n",
> +		       entry->d->str, p->fd, p->pid);
> +		return -1;
> +	}

> +	for_each_pstree_item(t) {
> +		TaskKobjIdsEntry *ids = t->ids;
> +
> +		if (ids->has_pid_ns_id && ids->pid_ns_id == nfi->nfe->ns_id) {

How can we have images with FD_TYPES__NS files but with pstree items without the has_xxx_ns_id?

> +			item = t;
> +			nd = &ns_desc_array[NS_TYPES__PID];
> +			break;
> +		} else if (ids->has_net_ns_id && ids->net_ns_id == nfi->nfe->ns_id) {
> +			item = t;
> +			nd = &ns_desc_array[NS_TYPES__NET];
> +			break;
> +		} else if (ids->has_ipc_ns_id && ids->ipc_ns_id == nfi->nfe->ns_id) {
> +			item = t;
> +			nd = &ns_desc_array[NS_TYPES__IPC];
> +			break;
> +		} else if (ids->has_uts_ns_id && ids->uts_ns_id == nfi->nfe->ns_id) {
> +			item = t;
> +			nd = &ns_desc_array[NS_TYPES__UTS];
> +			break;
> +		} else if (ids->has_mnt_ns_id && ids->mnt_ns_id == nfi->nfe->ns_id) {
> +			item = t;
> +			nd = &ns_desc_array[NS_TYPES__MNT];
> +			break;
> +		}
> +	}

> +int collect_ns_files(void)
> +{
> +	return collect_image(CR_FD_NS_FILES, PB_NS_FILES,
> +			     sizeof(struct ns_file_info),
> +			     collect_one_nsfile);

v0.5 crtools might bring us images w/o this file.

> +}
> +



More information about the CRIU mailing list