[CRIU] [RFC][PATCH 0/3] Proposal for native (w/o plugins) support for external bind mounts v2
Andrew Vagin
avagin at parallels.com
Fri Jun 6 04:21:01 PDT 2014
On Fri, Jun 06, 2014 at 03:14:04PM +0400, Pavel Emelyanov wrote:
> On 06/06/2014 03:10 PM, Andrew Vagin wrote:
> > On Thu, Jun 05, 2014 at 09:49:38AM -0700, Saied Kazemi wrote:
> >> Pavel,
> >>
> >> Actually the first attempt is working, albeit with a little help. So I don't
> >> think we need to _replace_ the entire path that is relative to the FS's root
> >> with what is passed to CRIU on the command line. We just need to find the
> >> missing part of the pathname and prepend it to the relative path.
> >>
> >> Let's look at the following realistic example from Docker. Docker bind mounts
> >> the container's /etc/host as follows:
> >>
> >> mount /var/lib/docker/containers/<ID>/hosts /var/lib/docker/vfs/dir/<ID>/etc/
> >> hosts
> >>
> >> The container's root is at /var/lib/docker/vfs/dir/<ID>. For container's /etc/
> >> hosts, CRIU records /containers/<ID>/hosts as source during dump. On restore,
> >> CRIU already has the container's root and ./etc/hosts within it, so all it
> >> needs is the leading /var/lib/docker for external bind mount. In other words,
> >> there is no need replacing the entire path which is --by the way-- dynamically
> >> generated for each container and not always easy to figure out.
> >>
> >> Does it make sense?
> >
> > I'm not sure that I understand you. Look at this:
> >
> > I just want to show mountinfo for a real docket CT.
> >
> > $ cat /proc/1554/mountinfo
> > 102 68 0:33 / / rw,relatime - aufs none rw,si=d75b2efa562f7b3
> > 103 102 8:1 /var/lib/docker/init/dockerinit-0.9.1 /.dockerinit ro,relatime - ext4 /dev/disk/by-uuid/291e7b1a-8396-44cf-9927-578b3401d0bd rw,errors=remount-ro,data=ordered
> > 104 102 8:1 /var/lib/docker/containers/37192b3177f945beb4a92e182638652b35fa71b14ae5b11072e4bfe22e21d280/config.env /.dockerenv ro,relatime - ext4 /dev/disk/by-uuid/291e7b1a-8396-44cf-9927-578b3401d0bd rw,errors=remount-ro,data=ordered
> > 105 102 0:16 /resolvconf/resolv.conf /etc/resolv.conf ro,relatime - tmpfs tmpfs rw,size=205004k,mode=755
> > 106 102 8:1 /var/lib/docker/containers/37192b3177f945beb4a92e182638652b35fa71b14ae5b11072e4bfe22e21d280/hostname /etc/hostname ro,relatime - ext4 /dev/disk/by-uuid/291e7b1a-8396-44cf-9927-578b3401d0bd rw,errors=remount-ro,data=ordered
> > 107 102 8:1 /var/lib/docker/containers/37192b3177f945beb4a92e182638652b35fa71b14ae5b11072e4bfe22e21d280/hosts /etc/hosts ro,relatime - ext4 /dev/disk/by-uuid/291e7b1a-8396-44cf-9927-578b3401d0bd rw,errors=remount-ro,data=ordered
> > 108 102 0:35 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
> > 109 102 0:36 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
> > 110 102 0:37 / /dev/shm rw,nosuid,nodev,noexec,relatime - tmpfs shm rw,size=65536k
> > 111 102 0:38 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
> > 112 102 0:12 /7 /dev/console rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
> >
> > So we have two types of bind-mounts:
> > * /var/lib/docker/containers/CTID
> > * /dev/console, /etc/resolv.conf
> >
> > and the option should be able to handle all these cases...
> >
> > For example:
> >
> > on dump:
> > --ext-mount s:/var/lib/docker/containers/37192b3177f945beb4a92e182638652b35fa71b14ae5b11072e4bfe22e21d280/=CTPATH
> > all source subpath is replaced on CTPATH
>
> There's no such thing as "source subpath". If /var/lib is not directory on /, but
> a mountpoint, criu would only see the /docker/containers/ID/... paths in mountinfo.
I know this and in this case you will need to say
--ext-mount s:/docker/containers/37192b3177f945beb4a92e182638652b35fa71b14ae5b11072e4bfe22e21d280/=CTPATH
or criu can cut "/var/lib" and compare a device number to be sure that a
bind-mount belons to the specified path.
>
> > --ext-mount d:/dev/console=console
> > a source path is set to "console", if a destination path is equal to /dev/console
> >
> > on restore
> > --ext-mount CTPATH=/mnt/var/lib/docker/containers/37192b3177f945beb4a92e182638652b35fa71b14ae5b11072e4bfe22e21d280/
> > --ext-mount console=/dev/tty98
> >
> > Is this what you suggest?
>
> Thanks,
> Pavel
More information about the CRIU
mailing list