CID 157804 (#1 of 1): Missing varargs init or cleanup (VARARGS)
16. missing_va_end: va_end was not called for tmp.
v2: typo fix
Reported-by: Mr Coverity
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
CID 157800 (#1 of 1): Missing break in switch (MISSING_BREAK)
unterminated_case: The case for value 1071 is not terminated by a 'break' statement.
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
CID 157801 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
19. negative_returns: fd is passed to a parameter that cannot be negative.
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
crtools binary is linked with the C library and could rely on all the
services this library is providing, including system calls.
Thus it doesn't need to be linked with the builtin system calls code
made for the parasite/restorer binaries.
This patch does:
- remove the inclusion of syscall.h
- replace all call to sys_<syscall>() by C library <syscall>()
- replace unwrapped system calls by syscall(SYS_<syscall>,...)
- fix the generated compiler's issues.
There should not be any functional changes. The only 'code' changes is
appearing in locks.h when futex is called through the C library, the
errno value is fetched from errno variable instead of the return
value.
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The CRIU internal define of CLONE_SUBNS should not be put in
syscall-types.h since this define is not part of a system call.
This move is required to prepare the removal of syscall.h from the
component of crtools binary.
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The file include/prctl.h should define the struct prctl_mm_map only if
it is not already defined in the system include file linux/prctl.h.
The definition should be part of the '#ifndef PR_SET_MM_MAP' block
since this structure is not defined in that case.
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
It is missged in first place and may cause
problem on exiting via alarm hanling.
Reported-by: Igor Sukhih <igor@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
All processes should exit if an user presses ctrl-c.
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Skip it till remap-links are supported.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Test checks that a deleted file content in a deleted parent directory
restores right. Initially directory is created in a separate mount,
to check the ghost file is created in right mount and link() in
rfi_remap() is working.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This patch makes ghost files to restore with the right path.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Since a deleted file may belong to a deleted directory
(which, in turn, may belong to another deleted, etc),
it's necessary to recreate all missing dentries in the path.
Doing this in mkreg_ghost() is not a good idea, because
another ghost file may need some of the dentries in the path,
and this requires to do refcouting of recreated directories.
To avoid this, we restore a ghost file in the first existing
parent directory of the patch. This guarantees, the ghost file
will be in the same mount with target file (rfi_remap() needs
that, because it uses link()).
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The issue here is that ARCH is not overwritten if the caller Makefile
already define it, and the upper Makefile is not overwriting the ARCH
define to "arm", when it is "armv7l" for instance, so the SRCARCH is
set to "armv7l" which is wrong.
With this patch, SRCARCH is using the inherinted define if called from
the top level Makefile.
This is required to build test on armv7l architecture (qemu).
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Sometimes I get:
sudo ./zdtm.py run -t zdtm/live/static/cgroup03
umount: /home/tycho/packages/criu/test/zdtm.qPwsoO: target is busy
(In some cases useful info about processes that
use the device is found by lsof(8) or fuser(1).)
Traceback (most recent call last):
File "./zdtm.py", line 1401, in <module>
tst.available()
File "./zdtm.py", line 435, in available
subprocess.check_call(["flock", "zdtm_mount_cgroups", "./zdtm_mount_cgroups"])
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['flock', 'zdtm_mount_cgroups', './zdtm_mount_cgroups']' returned non-zero exit status 1
let's use a lazy unmount so we avoid this.
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
cgroup.sane_behavior is read only (and in fact, the value is always 0), so
we don't need to c/r this value.
Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
We have two separate cases 1) mount is external - has mi->external set,
2) mount is internal - mi->external == 0. For those two cases we need
separate decesions on making moutn private.
In both cases we need private remount if:
a)mount does not have master_id and shared_id
or
b)if mount has different shared_id from bind source.
But do not private remount if has master_id or it will be lost. As after
setting private the mount is alone in its shared group so setting master
will silently fail as kernel can not find any for our mount.
(see do_make_slave)
https://jira.sw.ru/browse/PSBM-42829
v2: rework patches 2/4 and 4/4 together and no need then in 3/4
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
AutoFS will need to create write pipe end file descriptor, if it was closed.
Thus, pipe_info structure have to be exported.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This is a precursor patch for AutoFS mount restore.
To restore AutoFS indirect mount points, we have to create mount point dentries.
This can do only the process with pgrp, configured to mount. Process, which
does AutoFS mount call (init) at that moment is not.
Restoring actual pgrp before sid breaks sid restoring.
Thus, restoring of sid is required to make process group leader.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
In the most cases, file descriptor is not need in this function.
It's need in the case of creating a regular file only. So we can
use chown() instead of fchown(), and operate with a path directly.
The patch moves copying content of a regular file to new function
mkreg_ghost(). This will be used in next patches. Also, parameter
gf will be used.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Although we don't want to restore the values on these files, we definitely
do want to restore the permissions, as certain container engines (lxc) make
use of this.
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
These are present in every cgroup, so let's dump them.
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The root mount is always external and master_id is external too.
It's required to validate mounts. We already do this on restore,
but we need to do this on dump too. Otherwise we will get the error:
Mount %d %s (master_id: %d shared_id: %d) has unreachable sharing. Try --enable-external-masters.
https://jira.sw.ru/browse/PSBM-43260
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
If for some reason ptrace_poke_area return error
we might left dumpee with memfd descriptor opened.
Later in code we remove out injected blob making
dumpee to look untouched but descriptor will hang there.
lsof from container output:
| systemd-u 48 root 6u REG 0,4 0 53855 /memfd:CRIUMFD (deleted)
Thus lets close it immediately.
https://jira.sw.ru/browse/PSBM-43199
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
criu detaches from tasks in freezer_detach() in this case
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
We need to detach from all processes before waiting the root
task, because one of these processes may collect processes from a
target pid namespace. The pid namespace is destroyed only when all
processes have been killed and collected.
https://jira.sw.ru/browse/PSBM-43089
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This fixes the following test error:
FAIL: binfmt_misc.c:111: mount failed (errno = 1 (Operation not permitted))
CRIU tests (./test/zdtm.py run -a) passed.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
There's only one user of it, so better to reshuffle the arg set.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
If we happen to get 0 as the fd for the mountpoint, there is an error:
(00.280617) Dumping task cwd id 0x2b root id 0x2b
(00.280697) mnt: Dumping mountpoints
(00.280702) mnt: 132: 34:/ @ ./run/lock
(00.280714) mnt: Path `/run/lock' resolved to `./run/lock' mountpoint
tar: /proc/self/fd/0: Cannot open: Not a directory
tar: Error is not recoverable: exiting now
(00.283581) Error (util.c:666): exited, status=2
(00.283598) Error (mount.c:1220): mnt: Can't dump tmpfs content
Instead, let's not ever use 0 as the mountpoint fd.
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Introduce post-setup-namespaces action script
It needed to have possibility to run cutom script after mount
namespace is configured
Signed-off-by: Igor Sukhih <igor@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
It's a debug message, and it shouldn't be printed with
pr_perror(). Also, we interested in debug in the both
cases: magic and extensions.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Generate random binfmt_misc entries of different types
and check that they remain registered after the signal.
v2: pr_perror() in cleanup, .desc file and TST_DIR in Makefile
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This patch introduces basic CPU feature checking for PowerPC.
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>