[CRIU] [PATCH v3 1/2] restore: don't pass cgroup nsroot= option to mount()

Pavel Emelyanov xemul at virtuozzo.com
Mon Mar 28 00:57:36 PDT 2016


On 03/25/2016 10:26 PM, Tycho Andersen wrote:
> https://lkml.org/lkml/2016/3/21/777 introduces a new cgroup mount option
> called nsroot, but doesn't allow you to pass it to mount() to actually
> mount it. Let's chop this option off so that we don't get errors from
> mount().
> 
> There may be better places to chop this off (e.g. perhaps on dump),
> although I think it is useful to have it in there for debugging purposes,
> and only costs us a few extra bytes to keep it in the images since we're
> going to have other cgroup options anyways.
> 
> v2: handle the case where nsroot= is not the last mount option
> 
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
>  criu/mount.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/criu/mount.c b/criu/mount.c
> index a425828..eb8d058 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -2866,6 +2866,26 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
>  		/* FIXME: abort unsupported early */
>  		pm->fstype = decode_fstype(me->fstype, me->fsname);
>  
> +		if (pm->fstype->code == FSTYPE__CGROUP) {

Can we fix the pm->options in the ->munge callback as well? To keep the generic
code clean...

-- Pavel

> +			char *start;
> +
> +			start = strstr(pm->options, "nsroot=");
> +			if (start) {
> +				char *next = strchr(start, ',');
> +
> +				if (next) {
> +					/* skip the `,' but include the terminating \0 */
> +					memmove(start, next+1, strlen(next+1)+1);
> +				} else {
> +					if (start > pm->options && *(start-1) == ',')
> +						start--;
> +					*start = 0;
> +				}
> +
> +				pr_info("trimmed nsroot option from cgroup mount, opts now: %s\n", pm->options);
> +			}
> +		}
> +
>  		if (get_mp_root(me, pm))
>  			goto err;
>  
> 



More information about the CRIU mailing list