[CRIU] [PATCH 1/5] mnt: add --ext-mount-map auto option

Tycho Andersen tycho.andersen at canonical.com
Tue Apr 14 09:26:17 PDT 2015


On Tue, Apr 14, 2015 at 07:22:27PM +0300, Andrew Vagin wrote:
> On Tue, Apr 14, 2015 at 09:36:54AM -0600, Tycho Andersen wrote:
> > On Tue, Apr 14, 2015 at 11:06:49AM +0300, Andrew Vagin wrote:
> > > On Mon, Apr 13, 2015 at 08:58:21AM -0600, Tycho Andersen wrote:
> > > > On Mon, Apr 13, 2015 at 11:24:06AM +0300, Andrew Vagin wrote:
> > > > > On Fri, Apr 10, 2015 at 02:34:37PM +0000, Tycho Andersen wrote:
> > > > > > +static int resolve_external_mounts(struct mount_info *info)
> > > > > > +{
> > > > > > +	struct mount_info *m;
> > > > > > +	struct ns_id *ns = NULL, *iter;
> > > > > > +
> > > > > > +	for (iter = ns_ids; iter->next; iter = iter->next) {
> > > > > > +		if (iter->pid == getpid() && iter->nd == &mnt_ns_desc) {
> > > > > > +			ns = iter;
> > > > > > +			break;
> > > > > > +		}
> > > > > > +	}
> > > > > > +
> > > > > > +	if (!ns) {
> > > > > > +		pr_err("Failed to find criu pid's mount ns!");
> > > > > > +		return -1;
> > > > > > +	}
> > > > > > +
> > > > > > +	for (m = info; m; m = m->next) {
> > > > > > +		int ret, size;
> > > > > > +		char *p;
> > > > > > +		struct ext_mount *em;
> > > > > > +		struct mount_info *match;
> > > > > > +
> > > > > > +		if (m->parent == NULL || m->is_ns_root)
> > > > > > +			continue;
> > > > > > +
> > > > > > +		ret = try_resolve_ext_mount(m);
> > > > > > +		if (ret < 0 && ret != -ENOTSUP) {
> > > > > > +			return -1;
> > > > > > +		} else if (ret == -ENOTSUP && !opts.autodetect_ext_mounts) {
> > > > > > +			continue;
> > > > > > +		} else if (ret == 0) {
> > > > > > +			continue;
> > > > > > +		}
> > > > > > +
> > > > > > +		match = find_best_external_match(ns->mnt.mntinfo_list, m);
> > > > > > +		if (!match)
> > > > > > +			continue;
> > > > > > +
> > > > > > +		size = strlen(match->mountpoint + 1) + strlen(m->root) + 1;
> > > > > > +		p = xmalloc(sizeof(char) * size);
> > > > > > +		if (!p)
> > > > > > +			return -1;
> > > > > > +
> > > > > > +		ret = snprintf(p, size+1, "%s%s", match->mountpoint + 1, m->root);
> > > > > 
> > > > > Is it ok if match->root isn't /?
> > > > 
> > > > It should be, presumably that just means there were some extra steps
> > > > to set up the external mount point. Am I missing something?
> > > 
> > > Maybe we need something like this:
> > > 
> > > snprintf(p, size+1, "%s%s", match->mountpoint + 1, m->root + strlen(match->root));
> > 
> > I don't think m->root and match->root are relatable at all, though.
> > Consider:
> > 
> > in the container:
> > 
> > 94 93 0:21 /cgmanager /sys/fs/cgroup/cgmanager rw master:9 - tmpfs tmpfs rw,mode=755
> > 
> > on the host:
> > 
> > 27 17 0:21 / /sys/fs/cgroup rw shared:9 - tmpfs tmpfs rw,mode=755
> 
> Let's imagine that the host contains:
> 27 17 0:21 /sys/fs/cgroup/cgmanager /sys/fs/cgroup/cgmanager rw shared:9 - tmpfs tmpfs rw,mode=755
> 
> How this situation should be handled?
> 
> snprintf(p, size+1, "%s%s", "/sys/fs/cgroup/cgmanager", "/sys/fs/cgroup/cgmanager");

Doesn't the container then have something like:

94 93 0:21 / /sys/fs/cgroup/cgmanager rw shared:9 - tmpfs tmpfs rw,mode=755

so it ends up being

snprintf(p, size+1, "%s%s", "/sys/fs/cgroup/cgmanager", "/");

?

Tycho

> p = "/sys/fs/cgroup/cgmanager/sys/fs/cgroup/cgmanager"
> 
> I think it isn't what we want to get. Sorry if I miss something.
> 
> > 
> > Here /sys/fs/cgroup/cgmanager is bind mounted from the host to inside
> > the container (to the same path, not that it matters).
> > 
> > Tycho
> > 
> > > and check that strlen(match->root) <= strlen(m->root) in
> > > find_best_external_match().
> > > 
> > > Thanks,
> > > Andrew


More information about the CRIU mailing list