This will lead to segmentation fault.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Type dev_t corresponds to "unsigned long".
v2: explicitly cast to "long"
Signed-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Type dev_t corresponds to "unsigned long".
Signed-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
In file included from /home/travis/build/xemul/criu/criu/include/autofs.h:16:0,
from autofs.c:7:
/usr/include/linux/auto_fs.h:54:12: error: ‘NAME_MAX’ undeclared here (not in a function)
char name[NAME_MAX+1];
In file included from /home/travis/build/xemul/criu/criu/include/autofs.h:16:0,
from autofs.c:7:
/usr/include/linux/auto_fs.h:54:12: error: ‘NAME_MAX’ undeclared here (not in a function)
char name[NAME_MAX+1];
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The following error happens when building CRIU on Fedora 22:
CC autofs.o
autofs.c: In function ‘autofs_mount’:
autofs.c:892:9: error: implicit declaration of function ‘add_post_prepare_cb’ [-Werror=implicit-function-declaration]
ret = add_post_prepare_cb(autofs_add_mount_info, mi);
^
cc1: all warnings being treated as errors
Adding forward declaration of add_post_prepare_cb resolves the issue.
Signed-off-by: Mike Rapoport <rapoport@il.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The only way to check, whether autofs migration is supported from the kernel
side is to check actual mount point options (search for "pipe_ino" option).
This checker first tries to find autofs on host. If there is no any, temporary
mounts autofs by itself.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Required for test/zdtm/static/autofs test.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
1) Support autofs kernel-user exchange protocol
2) Test mounts: direct, indirect, offset (?) (migrated and operational).
3) Test cases, when write end of the pipe is closed, and when it's not.
4) Test catatonic mounts.
5) Test nested mounts are migrated (tmpfs suits it good)
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
In case of mounting AutoFS indirect mount points, target dentry doesn't exist
and has to be created.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
AutoFS mount point is managed by user space daemon, which receives requests
from kernel via pipe, passed on mount operation.
Kernel hold write end, while user space process - read end.
Thus, for successfull AutoFS migration, this connection has to be restored.
Autofs restore is tricky. Mount point is created by init process in pair with
per-mount context to be able to fix up actual kernel-userspace pipe
connection, when all the mount points are restored.
The problems with restoring pipe connection are:
1) It has to be done from actual AutoFS mount point master process context,
because pipe and pgrp values are taken from current in kernel.
2) Actual mounts are created by "init" process, and mount point owner (master)
have to set later.
3) To update mount point master one requires an opened write end of the pipe.
To provide AutoFS mount point master with resources, mentioned above, the
following was implemented:
1) If mount master doesn't have write pipe end opened, it is created as a
clone of read pipe end file descriptor and added to master's fds list. This
end is required to reconfigure mount point master.
2) Another pipe fle is created with explicit "post_open" callback, which is
used for actual mount point reconfiguration.
3) Mount point in created by init process. Mount data, required to restore
the owner, is copied to shared memory location by post-mount callback.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This structures and helpers are needed to simplify autofs mounts reconfiguring
during restore.
Note: taken from automount package.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This helper is used by autofs restore to add temporary pipe structures.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This helpers will be used by autofs restore to create temporary pipe
descriptors.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This list contains all per-process used file fdinfo's, sorted by fd number.
Will be used to safely create new artificial file descriptors and also allow
to recreate temporary descriptors with original number, if possible, like
AutoFS tries to preserve original pipe write end descriptor, when it was
closed.
This patch also adds a couple of simple helpers to find unused file
descriptor:
1) fd_is_used() does exactly what it is named
2) find_unused_fd() returns "hint_fd" if unused or last used descriptor plus
one.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
AutoFS mount point is managed by user space daemon, which receives
requests from kernel via pipe, passed on mount operation.
Kernel hold write end, while user space process - read end.
Thus, for successful AutoFS migration, this connection has to be
restored.
During this stage, all the autofs parameters and parsed and collected in
per-mount autofs structure. It also does check that autofs mounts is not in
interim state.
Below are major tricks to be performed to dump AutoFS mount:
1) Read end of the pipe in the process have to be discovered: it will be used
to restore the pipe in case of write pipe end in closed in the process.
Note: migration of AutoFS mounts, which process group leader doesn't have read
pipe end opened is not supported.
2) Read pipe end has to be empty. Otherwise autofs is an interim state.
Interim state is determined by control pipe contents: if it's not empty, then
it means, that kernel requested some operation (mount/umount), which is in
process right now.
In case of pipe is not empty, dump is aborted.
3) Mount points are collected (parsed) from initial pid namespace, which leads
to real pgrp value in AutoFS options instead of virtual one. This have to be
fixed.
Note: we don't care about virtual pgrp in case of catatonic mounts
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Autofs uses packetized pipe (with O_DIRECT), migration of which is not
supported.
Luckely, because we support only empty autofs pipes, they can be collected
into some list and then explicitly treated as normal pipes on dump.
Note: packetized mode is set by kernel inself on mount operation. So, we don't
need to carry the flag at all.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This entry will be used to carry all the autofs parameters, required to
restore mount point.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This device doesn't support read or write operations and is expected to be
created by external process.
Thanks to that, regular dump options suits this device.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
CRIU fails to dump processes that have a file descriptor pointing
to the /proc folder, because check_path_remap returns error code
in that case. Fix: return 0 instead.
Signed-off-by: Andrei Tuicu <andrei.tuicu@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This is supposed to be an else if.
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Otherwise next strcat get confused
| (00.024843) 26: Error (files-reg.c:1528): Can't open file dev/pts/g:��^?ptmx on restore: No such file or directory
| (00.024846) 26: Error (files-reg.c:1470): Can't open file dev/pts/g:��^?ptmx: No such file or directory
| (00.024849) 26: Error (tty.c:545): tty: Can't open dev/pts/g:��^?ptmx: No such file or directory
Reported-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Tested-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
In commit c6bc7259c we've started to carry @mode of the
files we're opening on restore, implying they are
static and should not be changed. This is true for
regular files but the pty peers are created
dynamically so if someone have set some special
mode beore the checkpoint procedure we will fail
on restore when regular file engine test it. So lets
setup @mode unconditionally.
https://travis-ci.org/xemul/criu/jobs/140011141
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Otherwise on some older environments like RHEL7 it will fail to build with:
CC pagemap.o
pagemap.c: In function ‘punch_hole’:
pagemap.c:54:40: error: ‘FALLOC_FL_PUNCH_HOLE’ undeclared (first use in this function)
ret = fallocate(img_raw_fd(pr->pi), FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
pagemap.c:54:40: note: each undeclared identifier is reported only once for each function it appears in
pagemap.c:54:63: error: ‘FALLOC_FL_KEEP_SIZE’ undeclared (first use in this function)
ret = fallocate(img_raw_fd(pr->pi), FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
make[2]: *** [pagemap.o] Error 1
CC: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
It uses --manage-cgroup full and can dump and restore cgroup of other tests.
Reported-by: Mr Jenkins
Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The deduplication code uses pagemap internal implementation details, so
it's better to have this code in the pagemap.c
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Here is a race when someone umounted something and this operation
isn't propagated into our namespace.
CRIU | Another process
-----------------------------------------------------------------
pivot_root(".", put_root) |
mount(put_root, MS_REC|MS_PRIVATE) |
| umount /xxx/yyy
| umount /xxx -> EBUSY
umount(put_root)
We do this to not affect mounts in put_root, but we can mask
these mounts as slave and this will work for us and for external
users.
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
pids.current is the current number of pids, not the maximum number allowed
(which is the thing we care about, that is set by the user).
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This property can't be written after there are children of the current
cgroup or once it has tasks, similar to the cpuset properties. So, let's
hoist this property into the "special" array.
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
memory.oom_control when read displays something like:
root@kernel:/sys/fs/cgroup/memory/zdtmtst# cat memory.oom_control
oom_kill_disable 0
under_oom 0
but when setting it, it expects a "1" or "0" when written. Let's parse out
this 1 or 0.
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Before, as long as we successfully closed the prop fd, the property write
would succeed.
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
For the previously added option to skip in-flight connections this adds
that option to the RPC interface. The skip in-flight connections is also
described in criu.txt.
Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This was 1.2 when we merged all file-locks images together. I think it is
good time to drop the legacy format.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Looks like it's the most appropriate place for those hooks.
Didn't know about those helpers - maybe I should have used
them in my code more widely instead of casts.
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>