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

Cyrill Gorcunov gorcunov at openvz.org
Fri May 17 10:19:05 EDT 2013


On Fri, May 17, 2013 at 05:57:32PM +0400, Pavel Emelyanov wrote:
> > +int dump_one_ns_file(int lfd, u32 id, const struct fd_parms *p)
> > +{
> > +	int fd = fdset_fd(glob_fdset, CR_FD_NS_FILES);
> > +	NsFileEntry nfe = NS_FILE_ENTRY__INIT;
> > +	struct ns_proc_entry *entry = p->arg;
> > +
> > +	nfe.id		= id;
> > +	nfe.ns_id	= generate_ns_id(p->pid, (unsigned int)entry->i_ino, entry->d);
> 
> 
> 
> > +	nfe.type	= entry->type;
> 
> The nfe.type is write-only field in this patch. Not nice.

I added this entry because you were asking for it. It's rather for
better understanding of what's being kept in image file, because
on restore it's not used (i though about writting "net", "ipc"
and etc here, but not sure). Maybe we should simply drop it completely
then.

> > +int collect_ns_files(void)
> > +{
> > +	if (access_image(CR_FD_NS_FILES, F_OK) == 0)
> > +		return collect_image(CR_FD_NS_FILES, PB_NS_FILES,
> > +				     sizeof(struct ns_file_info),
> > +				     collect_one_nsfile);
> > +	return 0;
> > +}
> > +
> 
> Other "optional" images are collected w/o access_image by simply checking
> the errno. Plz, use the same way.

OK.

> > @@ -277,9 +277,8 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op
> >  		 * entry thus choose which strategy to dump it with.
> >  		 */
> >  		if (parse_ns_proc(&p.link->name[1], p.link->len - 1, &found) == 0) {
> > -			pr_err("Dumping procfs namespace reference "
> > -			       "is not yet implemented\n");
> > -			return -1;
> > +			p.arg = &found;
> > +			return dump_ns_file(&p, lfd, fdinfo);
> 
> Internally dump_ns_file will call generate_ns_id. And your patch #6 does the same --
> splits this logic into two calls -- parse_ns_proc and generate_ns_id. Why not have
> a single function, that will just provide you ns ID if it's namespace link?

I tried to escape massive changing. get_ns_id and generate_ns_id have ns_desc
in arguments, so i don't understand how to make some general function which
would return ns ID at moment, letme think.


More information about the CRIU mailing list