[CRIU] [PATCH 1/5] mnt: add --ext-mount-map auto option
Tycho Andersen
tycho.andersen at canonical.com
Thu Apr 9 09:54:17 PDT 2015
On Thu, Apr 09, 2015 at 07:47:31PM +0300, Pavel Emelyanov wrote:
> > @@ -2360,7 +2510,8 @@ static int collect_mntns(struct ns_id *ns, void *__arg)
> > if (arg->for_dump && ns->pid != getpid())
> > arg->need_to_validate = true;
> >
> > - mntinfo_add_list(pms);
> > + if (!opts.autodetect_ext_mounts || ns->pid != getpid() || arg->really_collect_self_mounts)
> > + mntinfo_add_list(pms);
>
> I asked about this place on the v1 of the patch :)
>
> This if and the if for really_collect_self_mounts seems strange to me.
>
> There are two "types" of pms we can get here -- criu's one and non-criu's
> one. The former one should only be put into the global list if it's the only
> one at all, i.e. -- we're having the non-ns case.
>
> So the single if (ns->pid != getpid() || !(root_ns_mask & CLONE_NEWNS)) here
> should give us what we want.
>
> And, if I'm correct, the if in the next hunk can just go away.
Ah, right. This is leftover from when I was still mutating
root_ns_mask. I will resend a version of this.
Tycho
> -- Pavel
>
> > return 0;
> > }
> >
> > @@ -2371,15 +2522,34 @@ int collect_mnt_namespaces(bool for_dump)
> >
> > arg.for_dump = for_dump;
> > arg.need_to_validate = false;
> > + arg.really_collect_self_mounts = false;
> > +
> > + /*
> > + * XXX: this is a little bit of spaghetti. If we are autodetecting
> > + * external mounts, we want to collect the criu pid's mountinfo (and
> > + * thus the whole mountns) so we can corrolate the external masters.
> > + * So we clear the mountns bit for this call to walk_namespaces.
> > + *
> > + * However, we don't want to add criu's mountns to the dump target
> > + * list if it isn't really going to be dumped, so we set the
> > + * really_collect_self_mounts flag if we really do want to collect
> > + * them above.
> > + */
> > + if (opts.autodetect_ext_mounts && !(root_ns_mask & CLONE_NEWNS)) {
> > + arg.really_collect_self_mounts = true;
> > + }
> >
> > - ret = walk_namespaces(&mnt_ns_desc, false, collect_mntns, &need_to_validate);
> > + ret = walk_namespaces(&mnt_ns_desc, opts.autodetect_ext_mounts, collect_mntns, &arg);
> > if (ret)
> > goto err;
> >
> > + if (resolve_external_mounts(mntinfo))
> > + goto err;
> > +
> > if (arg.need_to_validate) {
> > ret = -1;
> >
> > - if (collect_shared(mntinfo))
> > + if (collect_shared(mntinfo, true))
> > goto err;
> > if (validate_mounts(mntinfo, true))
> > goto err;
> >
>
More information about the CRIU
mailing list