[CRIU] [PATCH RFC 00/16] Open files in proper namespaces

Andrew Vagin avagin at parallels.com
Wed Apr 9 02:49:04 PDT 2014


On Wed, Apr 09, 2014 at 01:23:52PM +0400, Pavel Emelyanov wrote:
> On 04/09/2014 03:34 AM, Andrey Vagin wrote:
> > Recently the mnt_id field was added in /proc/PID/fdinfo/X.
> > It allows us to know from which mount a file has been opened.
> > It's significant, if a few mount namespaces are restored.
> > 
> > Now mnt_id is saved for each file and on restore files are opened in
> > proper mount namespaces.
> 
> Nice, but where are the "proper mount namespaces" themselves?

[PATCH 00/13] Restore nested mount namespaces (v2)


Namespaces are restored before files and we know a pid of one process
from each namespace. So we look up namespace for each file, than open
/proc/PID/root and call openat(root_fd, path).

Actually we open /proc/PID/root only if a previous file was opened in
another namespace.

> > Andrey Vagin (16):
> >   proc_parse: parse fdinfo to get pos and flags
> >   proc_parse: parse mnt_id from /proc/PID/fdinfo/FD
> >   namespaces: dump mount namespaces before tasks
> >   mount: save mount tree for each namespace
> >   files: save mnt_id on fd_param
> >   files: save mnt_id for reg files
> >   fix mount: save mount tree for each namespace
> >   files-ids: generate id-s accoding with mnt_id, st->st_dev and
> >     st->st_ino
> >   servicefd: add a service fd for current root
> >   restore: look up root for each file
> >   zdtm: mark all mounts as private for one call
> >   zdtm: reexec the mountpoints test in a target mntns
> >   files: open ghost file relative to the proper root
> >   zdtm: check opened files in a second mntns
> >   mount: print error message if readlinkat failed
> >   mount: add a fast path for mntns_collect_root
> > 
> >  cr-dump.c                           | 55 +++++++++++++++++++++-------
> >  cr-restore.c                        |  3 ++
> >  file-ids.c                          | 32 ++++++++++-------
> >  files-reg.c                         | 38 ++++++++++++++++++--
> >  files.c                             | 17 ++++-----
> >  include/file-ids.h                  |  5 +--
> >  include/files.h                     |  2 ++
> >  include/mount.h                     |  6 +++-
> >  include/namespaces.h                |  9 ++++-
> >  include/proc_parse.h                |  7 ++++
> >  include/servicefd.h                 |  1 +
> >  mount.c                             | 71 ++++++++++++++++++++++++++++++++++---
> >  namespaces.c                        | 68 ++++++++++++++++++++---------------
> >  proc_parse.c                        | 25 ++++++++++++-
> >  protobuf/regfile.proto              |  1 +
> >  test/zdtm.sh                        |  1 +
> >  test/zdtm/lib/test.c                | 18 ++++++----
> >  test/zdtm/live/static/mountpoints.c | 50 +++++++++++++++++---------
> >  18 files changed, 310 insertions(+), 99 deletions(-)
> > 
> 
> 


More information about the CRIU mailing list