The version of ps in Alpine image by default is very limited.
It is based on the one from busybox and doesn't support options
such as '-p'.
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
Since commit 83301b5367a98 ("af_unix: Set TCP_ESTABLISHED for datagram sockets
too") in Linux kernel, SOCK_DGRAM unix sockets can have TCP_ESTABLISHED state
when connected. So we need to fix checks that assume SOCK_DRAM sockets cannot
have TCP_ESTABLISHED state.
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
The function run_tcp_server() was the last place CRIU was still using
the IPv4 only function inet_ntoa(). It was only used during a print, so
that it did not really break anything, but with this commit the output
is now no longer:
Accepted connection from 0.0.0.0:58396
but correctly displaying the IPv6 address
Accepted connection from ::1:58398
if connecting via IPv6.
Signed-off-by: Adrian Reber <areber@redhat.com>
An issue with dumping deleted reg files in overlayfs:
After deleting a file originated from lower layer in merged dir,
fstat() on the /proc/$pid/map_files symlink returns st_nlink=1, while
linkat() fails with errno ENOENT.
Signed-off-by: langyenan <ianlang@tencent.com>
Looking at CI logs there are often messages like:
"[WARNING] Option --keep-going is more useful when running multiple tests"
This commit removes '--keep-going' from single zdtm test runs.
Signed-off-by: Adrian Reber <areber@redhat.com>
Starting with gcc-11, Debian's armhf compiler no longer builds with
a default -mfpu= option. Instead it enables the FPU via an extension
to the -march flag (--with-arch=armv7-a+fp). criu's Makefile explicitly
passes its own -march=armv7-a setting, which overrides the +fp default,
so we end up with no FPU:
cc1: error: '-mfloat-abi=hard': selected architecture lacks an FPU
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
Debian testing has newer compiler version and running
cross compilation tests would allow us to catch any compilation
errors early.
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
The current debian stable release is Bullseye, not Buster. However, we
can use the 'stable' release instead. This would allow the CI to
automatically pick up updates in the future.
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
When we declare struct and at the same time declare variable pointer of
this struct type, it looks like clang-format threats "*" as a
multiplication operator instead of indirection (pointer declaration)
operator and puts spaces on both sides, which looks wrong.
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This is a test for "ghost/mount: allocate remounted_rw in shmem to get
info from other processes" patch, without the patch test fails with:
############# Test zdtm/static/mntns_ghost01 FAIL at result check ##############
Test output: ================================
16:15:19.607: 5: ERR: mntns_ghost01.c:95: open for write on rofs -> 7 (errno = 11 (Resource temporarily unavailable))
16:15:19.607: 4: FAIL: mntns_ghost01.c:121: Test died (errno = 11 (Resource temporarily unavailable))
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Previousely I din't mention this case because we had bad error handling
in ghost cleanup path.
Without these patch but with proper error handling for unlink we have an
error in mntns_ghost01 test:
Error (criu/files-reg.c:2269): Failed to unlink the remap file:
Read-only file system
Cherry-picked from Virtuozzo criu:
https://src.openvz.org/projects/OVZ/repos/criu/commits/151c859e1
Changes: check lookup_mnt_id return for NULL
Fixes: fd0a3cd9efb9 ("mount: remount ro mounts writable before
ghost-file restore")
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Previousely remounted_rw was not shared between all processes on
restore, thus cleanup didn't got this info from rfi_remap and these
mounts were wrongly left writable after restore.
Cherry-picked from Virtuozzo criu:
https://src.openvz.org/projects/OVZ/repos/criu/commits/3a1a592e7
Fixes: fd0a3cd9efb9 ("mount: remount ro mounts writable before
ghost-file restore")
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
If unlinkat fails it means that fs is in "corrupted" state - spoiled
with non-unlinked auxiliary directories.
While on it add fixme note as this function can be racy and BUG_ON if
path contains double slashes.
Cherry-picked from Virtuozzo criu:
https://src.openvz.org/projects/OVZ/repos/criu/commits/b7b4e69fd
Changes: simplify while loop condition, remove confusing FIXME, remove
excess !count check in favour of while loop condition check
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
1) On error paths need to close fd and unlock mutex.
2) Make rfi_remap return special return code to identify EEXIST from
linkat_hard, all other errors should be reported up.
3) Report unlinkat error as criu should not corrupt fs.
Cherry-picked from Virtuozzo criu:
https://src.openvz.org/projects/OVZ/repos/criu/commits/fe1d0be14
Changes: use close_safe(), fix order in "Fake %s -> %s link" error
message.
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Always wait() for forked child processes. It avoid zombie processes in
containers that don't have an init process reaping orphans.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
CentOS 8 goes EOL at the end of 2021. This switches our CentOS 8 based
tests to CentOS Stream 8 which should be supported until 2024.
Signed-off-by: Adrian Reber <areber@redhat.com>
Criu ignores SIGPIPE in most cases except swrk mode. And in the
following situtation criu get killed by SIGPIPE and have no chance
to do cleanup: Connection to page server is lost when we do disk-less
migration, criu send PS_IOV_FLUSH via a broken connction in
disconnect_from_page_server.
This patch let criu ignore SIGPIPE in all paths .
Signed-off-by: Liu Hua <weldonliu@tencent.com>
Now when we fixed clang-format complains in zdtm, let's switch to lates
clang-format available. This is effectively a revert of commit 07a2f0265
("ci: use Fedora 34 for lint CI runs").
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
The new freezer_state is a complete equivalent of old freezer_thawed
except for the initial value. If old freezer_thawed was not initialized
it was 0 and in freezer_restore_state were threated as if we need to
freeze cgroup "back", thus before this patch if criu dump failed before
freezing dumpee, criu always freeze dumpee in cr_dump_finish which is
wrong. Switching to freezer_state initialized with FREEZER_ERROR fixes
the problem.
v2: improve description, rename to origin_freezer_state
Signed-off-by: Liu Hua <weldonliu@tencent.com>
Clang-format v13 on my Fedora 35 complains about these hunks, more over
reading the formating we had before is a pain:
} else /* comment */
if (smth) {
fail("")
return -1;
}
Let's make explicit {} braces for else, this way it looks much better.
Fixes: 93dd984ca ("Run 'make indent' on all C files")
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Various I/O objects are unclosed when the object falls out of scope.
This can lead to non-deterministic behavior.
Also fixed a few missing list(). It doesn't play way with python3.
e.g., `random.shuffle(filter(...))` doesn't work.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
We see that tests mntns_ghost01 and unlink_fstat03 can run
simultaneousely and thus the former sees leftover link_remap.* files in
the test directory created by the latter, and the latter is still
running so it's ok to have link_remap.* at this point.
Let's implicitly make all --link-remap tests exclusive (not running in
parallel).
Fixes: #1633
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
We see error in centos8 ci on restore of socket-raw test:
inet: \tRestore: family AF_INET type SOCK_RAW proto 66
port 66 state TCP_CLOSE src_addr 0.0.0.0
Error (criu/sk-inet.c:834): inet: Can't create inet socket:
Protocol not supported
Centos 8 kernel replaces IPPROTO_MPTCP(262) with "in-kernel" value
IPPROTO_MPTCP_KERN(66) on inet_create(), but later shows this inkernel
value to criu when listing sockets info. Same code in inet_create()
returns EPROTONOSUPPORT on the attempr to create socket with
IPPROTO_MPTCP_KERN. So this ci error is completely rh8 kernel related.
Kernel should not show "in-kernel" value to userspace. But anyway this
is already changed in Centos 9 kernel, so we can just skip socket-raw
test on Centos 8.
v2: use cirrus.yml
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
There is no option in clang not to merge as much binary operands as it
fits in column limit, but here we need each bit on new line to make it
readable, so let's disable clang-format for x86_ins_capability_masks.
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
A zombie process with 0 sid has a session leader in
outer pidns and has ignored SIGHUP. Criu has no idea
to restore this type of process, so fail the dumpping.
Signed-off-by: Liu Hua <weldonliu@tencent.com>
Automatic AlignTrailingComments fails to make those comments look right,
so let's do it manually, so that they both satisfy AlignTrailingComments
and also are human-readable.
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Just set all possible values 0-3 and chack if it persists.
Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
When one sets socket buffer sizes with setsockopt(SO_{SND,RCV}BUF*),
kernel sets coresponding SOCK_SNDBUF_LOCK or SOCK_RCVBUF_LOCK flags on
struct sock. It means that such a socket with explicitly changed buffer
size can not be auto-adjusted by kernel (e.g. if there is free memory
kernel can auto-increase default socket buffers to improve perfomance).
(see tcp_fixup_rcvbuf() and tcp_sndbuf_expand())
CRIU is always changing buf sizes on restore, that means that all
sockets receive lock flags on struct sock and become non-auto-adjusted
after migration. In some cases it can decrease perfomance of network
connections quite a lot.
So let's c/r socket buf locks (SO_BUF_LOCKS), so that sockets for which
auto-adjustment is available does not lose it.
Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This is a new kernel feature to let criu restore sockets with kernel
auto-adjusted buffer sizes.
Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
We want to also c/r socket buf locks (SO_BUF_LOCKS) which are also
implicitly set by setsockopt(SO_{SND,RCV}BUF*), so we need to order
these two properly. That's why we need to wait for sk_setbufs to finish.
And there is no much point in seting buffer sizes asyncronously anyway.
Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
When exceptions are raised during testing, the image streamer process
should be terminated as opposed to being left hanging.
This could lead to the whole test suite to be left hanging as it waits
for all child processes to exit.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
Fedora 35 comes with clang 13 which provides different results for
clang-format than clang 12 in Fedora 34.
Signed-off-by: Adrian Reber <areber@redhat.com>
Newer kernels (5.11) require echo 1 > /proc/sys/vm/unprivileged_userfaultfd
Without the 'echo 1' the kernel prints a message like this:
uffd: Set unprivileged_userfaultfd sysctl knob to 1 if kernel faults must be handled without obtaining CAP_SYS_PTRACE capability
Signed-off-by: Adrian Reber <areber@redhat.com>
Previously, `open_image(CR_FD_RULE, O_RSTR, pid)` was called twice.
Opening an image file twice is not allowed when streaming the image.
This commit optimizes the code to only open the image file once.
Also improved the error path in restore_ip_dump().
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
We see that on criu-ns dump/restore/dump of the process which initially
was not a session leader (with --shell-job option) we see sid == 0 for
it and fail with something like:
Error (criu/cr-dump.c:1333): A session leader of 41585(41585) is outside of its pid namespace
Note: We should not dump processes with sid 0 (even with --shell-job) as
on restore we can can put such processes from multiple sessions into
one, which is wrong.
Fixes: #232
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This simplifies the code by removing excess recursion and reusing
standard function to walk over file-tree instead of opencoding it.
This addresses problem mentioned in my review comment:
https://github.com/checkpoint-restore/criu/pull/1495#discussion_r677554523
Fixes: 0db135ac4 ("util: add rm -rf function")
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
v2: split error checking from index variable initialization
v3: use PRIx64 for printing dev_t
Signed-off-by: fu.lin <fulin10@huawei.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
We use here "%#x" printf specifier in pie code, but sbuf_printf core pie
printing function knows nothing about '#' specifier. More over simple
"%x" in pie does same as "%#x" in stdio printf, see print_hex* functions
add "0x" before hex numbers.
We've got this error on vzt-cpt runs in Virtuozzo:
(04.750271) pie: 158: Adjust id
Error: Unknown printf format %#
So to fix it we can just remove '#'.
Fixes: ecd432fe2 ("timerfd: Implement c/r procedure")
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
ShellCheck reports the following problems:
SC2086: Double quote to prevent globbing and word splitting.
SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
SC1091: Not following: ../env.sh was not specified as input (see shellcheck -x).
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>