The devpts fs should be mounted and its content is restored,
when crtools restores terminals.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
When dumping a tmpfs mount we need to take its contents with us.
So, use tar for it and put it into the image dir.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Binfmt is global fs. We could check for its inhabitants intersect on
source and destination, but for the 1st time it's enough just to check
this one being empty.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The routines are supposed to provide a DIR * for a givem mountpoint. Currently
it aborts when a mountpoint is overmounted, but this should be fixed eventually.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We need to dump content of some fs like binfmt_misc, tmpfs, ... To facilitate
this the existing list of filesystems is turned into an array of structures
with dump and restore callbacks. Each FS may declare them they need.
v2: rework encode/decode_fstype not to do it twice.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It's global, so it doesn't require any actions, they should be only mounted.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The pb_read thing is no longer a macros. This will allow to
factor out objects collecting on restore.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
- Use sizeof instead of PATH_MAX constant
- Place EOS exactly after read data end
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The option is -r|--pivot-root and an argument is a path to new root.
A root task will make pivot_root. LXC CT does that, so we need that
for restoring.
v2: s/pivot-root/root/
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The list of mounts is used by inotify to restore a watch with open-by-handle. The problem
is that after the clean_mnt_ns is done the mntinfo list is no longer relevant.
Fix it by freeing the old one and initializing the new with the read-from-image stuff.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
If we dump tasks with mntns, we should look at pathes from point of a mntns root.
Now we support a situation when a root of an init task has the same root as the
mntns root, because we have not another way to get a root of mntns.
A path to an unix socket is copied, because the origin copy will be gone
out from the function, where it was created.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This one walks the 'plain' image file, i.e. the one with straignt <magi>[<size><entry>]*
format, and prints each message. Saves lots of lines of code.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
1. Mountinfo should be collected after we have forked into new namespace (strictly
speaking this is so)
2. When restoring a mnt ns we can reuse the collected mntinfos rather than reading
them again.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Only support virtual filesystems mount. No bindmounts or disk fs
due to non trivial resolving of devices names and binmount sources.
Will be implemented later.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Two walkers -- in forward and reverse directions -- are required
for correct (u)mounting of subtrees. Implement them using a helper
macro which walks the tree in both directions.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Namespace restore goes in two steps -- first, clean old mountpoints
(except root) that are left after clone(CLONE_NEWNS) call. Next,
repopulate the namespace with new mountpoints (except root) read
from the image file.
This patch adds the skeleton for the above -- reading the mountpoints
from current proc and image and calling for mount/umount. The real
action will come in further patches.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Build a tree of mountpoins that can be (u)mounted in a straight
(forward or backward) order without EBUSY errors.
The tree is built in two steps -- first create hierarchy based
on mount iDs. Next -- resort siblings in the path depth order.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Encode it in u32 since we have to check filesystem name anyway
(not everyone ie easily migratable).
Dump _any_ root fs as we need the root entry on restore though
do not mount it then -- it should be provided before crtools
restore start.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Dumping is straightforward -- just copy all the mount_info
fields into the new image file. Dump everything but fstype,
this one will come in a separate patch.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This structure will be used on restore and will be created
from the image, thus the name proc_ is not suitable.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Make the proc_mountinfo obtaned after parse form a single linked list.
That's much easier to handle and doesn't have an artificial limitation
of 64 items...
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
What is stored there is the path to mountpoint. The root
is the field previously named "parent root".
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v2:
- open_mount is cleaned up
- byte-stream hex conversion remains untouched since
strtol is flipping numbers to LE manner
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
At moment only open_mnt_root is there, which is
needed for inotify restore.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>