[CRIU] [PATCH 4/6] mnt: add --enable-external-masters option

Tycho Andersen tycho.andersen at canonical.com
Wed Apr 8 17:04:30 PDT 2015


On Wed, Apr 08, 2015 at 04:18:18PM +0300, Andrew Vagin wrote:
> On Tue, Apr 07, 2015 at 11:37:19PM +0000, Tycho Andersen wrote:
> > This option enables external (slave) bind mounts to be resolved.
> > 
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > ---
> >  crtools.c            | 11 +++++++++++
> >  include/cr_options.h |  1 +
> >  mount.c              |  3 +++
> >  3 files changed, 15 insertions(+)
> > 
> > diff --git a/crtools.c b/crtools.c
> > index fe77f39..095c86e 100644
> > --- a/crtools.c
> > +++ b/crtools.c
> > @@ -205,6 +205,7 @@ int main(int argc, char *argv[], char *envp[])
> >  		{ "feature",		required_argument,	0, 1063	},
> >  		{ "skip-mnt",		required_argument,	0, 1064},
> >  		{ "enable-external-sharing", no_argument, 	0, 1065 },
> > +		{ "enable-external-masters", no_argument, 	0, 1066 },
> >  		{ },
> >  	};
> >  
> > @@ -425,6 +426,9 @@ int main(int argc, char *argv[], char *envp[])
> >  		case 1065:
> >  			opts.enable_external_sharing = true;
> >  			break;
> > +		case 1066:
> > +			opts.enable_external_masters = true;
> > +			break;
> >  		case 'M':
> >  			{
> >  				char *aux;
> > @@ -461,6 +465,11 @@ int main(int argc, char *argv[], char *envp[])
> >  		return 1;
> >  	}
> >  
> > +	if (!opts.autodetect_ext_mounts && (opts.enable_external_masters || opts.enable_external_sharing)) {
> > +		pr_msg("must specify --ext-mount-map auto with --enable-external-{sharing|masters}");
> > +		return 1;
> > +	}
> > +
> >  	if (work_dir == NULL)
> >  		work_dir = imgs_dir;
> >  
> > @@ -655,6 +664,8 @@ usage:
> >  "                        attempt to autodetect external mount mapings\n"
> >  "  --enable-external-sharing\n"
> >  "                        allow autoresolving mounts with external sharing\n"
> > +"  --enable-external-masters\n"
> > +"                        allow autoresolving mounts with external masters\n"
> >  "  --manage-cgroups      dump or restore cgroups the process is in\n"
> >  "  --cgroup-root [controller:]/newroot\n"
> >  "                        change the root cgroup the controller will be\n"
> > diff --git a/include/cr_options.h b/include/cr_options.h
> > index 29be2c8..28bed45 100644
> > --- a/include/cr_options.h
> > +++ b/include/cr_options.h
> > @@ -64,6 +64,7 @@ struct cr_options {
> >  	struct list_head	new_cgroup_roots;
> >  	bool			autodetect_ext_mounts;
> >  	bool			enable_external_sharing;
> > +	bool			enable_external_masters;
> >  	bool			aufs;		/* auto-deteced, not via cli */
> >  };
> >  
> > diff --git a/mount.c b/mount.c
> > index 8835a81..7d565d8 100644
> > --- a/mount.c
> > +++ b/mount.c
> > @@ -691,6 +691,9 @@ static int resolve_external_mounts(struct mount_info *info)
> >  			if (opts.enable_external_sharing && pm->shared_id == m->shared_id)
> >  				match = true;
> >  
> > +			if (opts.enable_external_masters && pm->shared_id == m->master_id)
> > +				match = true;
> 
> if think this code should be inverted:
> 			if (!opts.enable_external_masters || pm->shared_id != m->master_id)
> 				match = false.
> 
> In your case, we can meet pm with another shared_id and set it as
> external, but it looks wrong. Do I miss something?

Ok, thinking about this case a bit more, if

pm->shared_id != m->master_id

that means the container has internal master/slave peering, but is
from an external bind mount. This means that we would need to re-work
do_mount_one/can_mount_now to understand external mounts in addition
to sharing. It could be done, but since it doesn't seem like a common
case, I'm inclined to just punt for now and print an error in this
case. If that's ok, I think I've got the rest of the set done and I
can post it.

Tycho

> > +
> >  			if (!match)
> >  				continue;
> >  
> > -- 
> > 2.1.4
> > 
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list