2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00
Commit Graph

10170 Commits

Author SHA1 Message Date
Nidhi Gupta
0c218746d5 Switch open-j9 alpine tests to python3
Signed-off-by: Nidhi Gupta <itsnidhi16@gmail.com>
2020-02-04 12:39:44 -08:00
Nidhi Gupta
1e9ff2aa03 Add Socket-based Java Functional Tests
Signed-off-by: Nidhi Gupta <itsnidhi16@gmail.com>
2020-02-04 12:39:44 -08:00
Adrian Reber
8b5dea33f6 travis: switch alpine to python3
Now that Python 2 has officially reached its end of life also switch the
Alpine based test to Python 3.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-02-04 12:39:44 -08:00
Nicolas Viennot
75a7442380 files: Add FD_CLOEXEC test 2020-02-04 12:39:44 -08:00
Nicolas Viennot
8255caf27b files: Remove O_CLOEXEC from file flags
The kernel artificially adds the O_CLOEXEC flag when reading from the
/proc/fdinfo/fd interface if FD_CLOEXEC is set on the file descriptor
used to access the file.

This commit removes the O_CLOEXEC flag in our file flags.

To restore the proper FD_CLOEXEC value in each of the file descriptors,
CRIU uses fcntl(F_GETFD) to retrieve the FD_CLOEXEC status, and restore
it later with fcntl(F_SETFD). This is necessary because multiple file
descriptors may point to the same open file.
2020-02-04 12:39:44 -08:00
Nicolas Viennot
2ac43cd426 python: Improve decoding of file flags
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
2020-02-04 12:39:44 -08:00
Nicolas Viennot
7622b7a70e files: fix ghost file error path
Signed-off-by: Nicolas Viennot <nicolas.viennot@twosigma.com>
2020-02-04 12:39:44 -08:00
Alexander Mikhalitsyn
acb42456dc zdtm: nft tables preservation test
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Signed-off-by: Alexander Mikhalitsyn <alexander@mihalicyn.com>
[Added test_author to zdtm test]
Signed-off-by: Dmitry Safonov <dima@arista.com>
2020-02-04 12:39:43 -08:00
Alexander Mikhalitsyn
e1c4871759 net: add nftables c/r
After Centos-8 nft used instead of iptables. But we had never supported nft rules in
CRIU, and after c/r all rules are flushed.

Co-developed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Signed-off-by: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
2020-02-04 12:39:43 -08:00
Nicolas Viennot
17c4a8b245 style: Enforce kernel style -Wstrict-prototypes
Include warnings that the kernel uses during compilation:
-Wstrict-prototypes: enforces full declaration of functions.
Previously, when declaring extern void func(), one can call func(123)
and have no compilation error. This is dangerous. The correct declaration
is extern void func(void).

Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
[Generated a commit message from the pull request]
Signed-off-by: Dmitry Safonov <dima@arista.com>
2020-02-04 12:39:42 -08:00
Nicolas Viennot
8bb3c17a0f style: Enforce kernel style -Wdeclaration-after-statement
Include warnings that the kernel uses during compilation:
-Wdeclaration-after-statement: enforces having variables declared at the top of scopes

Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
[Generated a commit message from the pull request]
Signed-off-by: Dmitry Safonov <dima@arista.com>
2020-02-04 12:39:27 -08:00
Adrian Reber
79559bef92 Fix tests on Ubuntu
It seems like Ubuntu introduced a overlayfs change which breaks CRIU:

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1857257

This disables overlayfs (unfortunately) in most tests by switching to
devicemapper or vfs.

Upstream kernels do not seem to have this problem.

This also adds the 'docker-test' for xenial which still has a working
overlayfs from CRIU's point of view.

Also adjust Podman Ubuntu package location

Podman Ubuntu packages are now available via OBS and no longer via PPA.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-02-04 12:39:05 -08:00
Radostin Stoyanov
8b467dd944 zdtm: Add test for SO_KEEPALIVE
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:05 -08:00
Radostin Stoyanov
d4e6fc2a0d socket: c/r support for SO_KEEPALIVE
TCP keepalive packets can be used to determine if a connection
is still valid. When the SO_KEEPALIVE option is set, TCP packets
are periodically sent to keep the connection alive.

This patch implements checkpoint/restore support for SO_KEEPALIVE,
TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT options.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:05 -08:00
Radostin Stoyanov
0980617e24 sockets: Remove duplicate variable assignment
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:05 -08:00
Radostin Stoyanov
00bb068785 scripts: alpine: Install py2 packages with pip
The py-future package has been renamed to py3-future [1] and py2 package
for yaml has been dropped [2].

[1] https://git.alpinelinux.org/aports/commit/main?id=316d44abaed13964e97eb43c095cd1b64e3943ad
[2] https://git.alpinelinux.org/aports/commit/main?id=e369c1fd7707a73f2c3e2b11b613198d9a4106de

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:05 -08:00
Nicolas Viennot
2e656222d7 crit: fix python3 encoding issues
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
2020-02-04 12:39:05 -08:00
Pavel Tikhomirov
4c46cbc4d8 x86/cpu: cleanup and improve xfeatures_mask check
Make xfeatures_mask check explicit. We were relying on our guess about
hardware "backward compatibility" and used ">" check here for a long
time. But it looks better to explicitly check that all xfeature bits
available on the source are also available on the destination.

For xsave_size we need to have smaller size on destination than on
source, because xsave operation on small allocated buffer may corrupt
the nearby data. So split up comments about xfeatures_mask and
xsave_size, as having single comment for quiet a different cases is less
understandable.

v2: improve comments, remove extra else-ifs, remove extra typecast

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2020-02-04 12:39:05 -08:00
Alexander Mikhalitsyn
55f7a571f2 zdtm: sysctl net.unix.max_dgram_qlen value preservation test
Test checks that if the /proc/sys/net/unix/max_dgram_qlen value has
been changed in process net namespace, then it is saved after c/r.

Signed-off-by: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
2020-02-04 12:39:05 -08:00
Cyrill Gorcunov
ebe3b52353 unix: sysctl -- Preserve max_dgram_qlen value
The /proc/sys/net/unix/max_dgram_qlen is a per-net variable and
we already noticed that systemd inside a container may change its value
(for example it sets it to 512 by now instead of kernel's default
value 10), thus we need keep it inside image and restore then.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
2020-02-04 12:39:05 -08:00
Cyrill Gorcunov
1d23dc4a30 mount: Order call_helper_process calls
When we do clone threads in a later stage of restore procedure
it may race with helpers which do call clone_noasan by self.

Thus we need to walk over each clone_noasan call and figure
out if calling it without last_pid lock is safe.

 - open_mountpoint: called by fusectl_dump, dump_empty_fs,
   binfmt_misc_dump, tmpfs_dump -- they all are processing
   dump stage, thus safe

 - call_helper_process: try_remount_writable -- called from
   various places in reg-files.c, in particular open_reg_by_id
   called in parallel with other threads, needs a lock
   remount_readonly_mounts -- called from sigreturn_restore,
   so in parallel, needs a lock

 - call_in_child_process: prepare_net_namespaces -- called
   from prepare_namespace which runs before we start forking,
   no need for lock

Thus call_helper_process should use lock_last_pid and
unlock_last_pid helpers and wait for subprocess to finish.

Same time put a warning text into clone_noasan comment
so next time we need to use it we would recall the pitfalls.

v2:
 - fix unitialized ret variable
v3:
 - use exit_code instead of ret

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2020-02-04 12:39:05 -08:00
Pavel Tikhomirov
2237666ac1 restorer/inotify: reorder inotify cleanup after waiting helpers and zombies
We've seen ppoll interrupted with signal in VZ7 CT migration tests, that
is because in the beggining of CR_STATE_RESTORE_SIGCHLD zombies and
helpers die, and that can trigger SIGCHILDs sent to their parents.

Adding additional debug (printing "Task..." for zombies and helpers) in
sigchld_handler I see:

  (15.644339) pie: 1: Task 10718 exited, status= 0
  (15.644349) pie: 1: Cleaning inotify events from 29
  (15.644359) pie: 1: Cleaning inotify events from 19
  (15.644367) pie: 1: Cleaning inotify events from 10

And previousely we had:

  (05.718449) pie: 104: Cleaning inotify events from 5
  (05.718835) pie: 330: Cleaning inotify events from 3
  (05.719046) pie: 1: Cleaning inotify events from 23
  (05.719164) pie: 80: Cleaning inotify events from 7
  (05.719185) pie: 1: Error (criu/pie/restorer.c:1287): Failed to poll from inotify fd: -4
  (05.719202) pie: 95: Cleaning inotify events from 6
  (05.719269) pie: 1: Error (criu/pie/restorer.c:1890): Restorer fail 1

So reordering cleanup and wait should fix it.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2020-02-04 12:39:05 -08:00
Andrei Vagin
af7e5f994b readme: github pull-requests is the preferred way to contribute
We will continue accepting patches.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:05 -08:00
Andrei Vagin
be43c3b840 cgroup: use new mount API to open the cgroup file system
It doesn't require to create a temporary directory and mount the proc
file system in it.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:05 -08:00
Andrei Vagin
76e4d31a3f net: use new mount API to open the sysfs file system
It doesn't require to create a temporary directory and mount the proc
file system in it.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:05 -08:00
Andrei Vagin
1a2d8ad7e1 mount: use new mount API to open the proc file system
It doesn't require to create a temporary directory and mount the proc
file system in it.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:05 -08:00
Andrei Vagin
4997a096e4 util: introduce the mount_detached_fs helper
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:05 -08:00
Andrei Vagin
b5b1c4ec45 kerndat: check whether the new mount API is supported of not
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:05 -08:00
Andrei Vagin
3ca09b1914 travis: ignore fails of podman-test
until it will not be fixed.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:05 -08:00
Nidhi Gupta
37220b3c41 Add File-based Java Functional Tests
Signed-off-by: Nidhi Gupta <itsnidhi16@gmail.com>
2020-02-04 12:39:05 -08:00
Dmitry Safonov
6ab2bdd940 zdtm/socket-tcp-fin-wait1: Use array index fro TEST_MSG
Fixes the following compile-error:
>  CC        socket-tcp-fin-wait1.o
> socket-tcp-fin-wait1.c:144:26: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
>                 if (write(fd, TEST_MSG + 2, sizeof(TEST_MSG) - 2) != sizeof(TEST_MSG) - 2) {
>                               ~~~~~~~~~^~~
> socket-tcp-fin-wait1.c:144:26: note: use array indexing to silence this warning
>                 if (write(fd, TEST_MSG + 2, sizeof(TEST_MSG) - 2) != sizeof(TEST_MSG) - 2) {
>                                        ^
>                               &        [  ]
> 1 error generated.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
434e6b92db Documentation: Add a hint about docker build
The original/old guide probably doesn't work anymore:
- the patch isn't accessible;
- criu now depends on more libraries not only protobuf

Still, keep it as it might be helpful for someone.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
1dbc835954 travis: Add armv7-cross as cross-compile test
Fixes: #455
Based-on-patch-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
bffa6e0ad0 build/zdtm: Use pkg-config to find includes/libs
Helps to cross-compile zdtm tests in case somebody needs it.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
3b24574b6d build/zdtm: Makefile hack for travis aarch64/armv8l
The very same hack to build aarch32 zdtm tests on armv8 Travis-CI
as in the commit dfa0a1edcb ("Makefile hack for travis
aarch64/armv8l")

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
70fae12509 build/zdtm: Support cross-build
Maybe not that useful, but only little change needed.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
1463c41119 build: Use SUBARCH
Instead of doing additional `uname -m` - use provided $(SUBARCH) to detect
what architecture flavour the build should produce the result for.

Fixes two things:
- zdtm make now correctly supplies $(USERCFLAGS)
- subtly fixes cross compilation by providing a way to specify $(SUBARCH)

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
df66aa99b6 build/nmk: Provide proper SUBARCH
It's always equal ARCH and not very useful (so nothing actually uses it).
Time for a change: SUBARCH now is meaningful and gives a way to detect
what kind of ARCH flavor build is dealing with.

Also, for cross-compiling sake don't set SUBARCH if the user supplied it.
(and don't call useless uname during cross compilation)

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
a4fa4162d4 build/nmk: Remove SRCARCH
It's not used anywhere now.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
25f6d4f72f build: Remove SRCARCH
SRCARCH is always equal ARCH. There are no rules when to use one or
another and architectures may forget to set one of them up.

No need for a second variable meaning the same and confusing people.
Remove it completely.

Self-correction [after some debug]: SRCARCH was different in one place:
zdtm Makefile by some unintentional mistake:
> ifeq ($(ARCH),arm64)
>         ARCH		?= aarch64
>         SRCARCH	?= aarch64
> endif

That meant to be "ARCH := aarch64" because "?=" would never work inside
that ifeq. Fix up this part of mess too.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00
Andrei Vagin
60bb5c7310 zdtm: Set --root path to 0700 on restore
Update zdtm tests to verify that CRIU does not require the --root
path to be accessible to the unprivileged user being restored when
restoring user namespace.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:04 -08:00
Radostin Stoyanov
90cbeadb66 zdtm: Replace if->continue with if->elif->else
Replacing the if->continue pattern with if->elif->else
reduces the number of lines while preserving the logic.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:04 -08:00
Radostin Stoyanov
9a50fbce72 man: Describe --root option requirements
These requirements have been described in

https://github.com/opencontainers/runc/blob/b133feae/libcontainer/container_linux.go#L1265

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:04 -08:00
Radostin Stoyanov
8ab3e40e3e restore: Create temp proc in /tmp
When restoring a container with user namespace, CRIU fails to create
a temporary directory for proc. The is because the unprivileged user
that has been just restored does not have permissions to access the
working directory used by CRIU.

Resolves #828

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:04 -08:00
Radostin Stoyanov
d99ee9753e mount: Bind-mount root via userns_call
When restoring a runc container with enabled user namespace CRIU fails
to mount the specified root directory because the path is under
/run/runc which is inaccessible to unprivileged users.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:04 -08:00
Radostin Stoyanov
b50b6ea09e mount: Add error messages
Suggested-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-02-04 12:39:04 -08:00
Mike Rapoport
75fcec0ecb travis: exclude uns tests for lazy-pages on newer kernels
Kernels 5.4 and higher will restrict availability of UFFD_EVENT_FORK only
for users with SYS_CAP_PTRACE. This prevents running --lazy-pages tests
with 'uns' flavor.

Disable 'uns' for lazy pages testing in travis for newer kernels.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
2020-02-04 12:39:04 -08:00
Mike Rapoport
8f45330d16 travis: group lazy-pages options
The amount of lazy-pages options keeps growing, let's put the common ones
into a variable.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
2020-02-04 12:39:04 -08:00
Michał Cłapiński
dc4677123b Checkpoint only specified controllers
Before this change CRIU would checkpoint all controllers, even the ones
not specified in --cgroup-dump-controller. That becomes a problem if
there's a cgroup controller on the checkpointing machine that doesn't
exist on the restoring machine even if CRIU is instructed not to dump
that controller. After that change everything works as expected.

Signed-off-by: Michał Cłapiński <mclapinski@google.com>
2020-02-04 12:39:04 -08:00
Dmitry Safonov
1c0716924b compel/criu: Add __must_check
All those compel functions can fail by various reasons.
It may be status of the system, interruption by user or anything else.
It's really desired to handle as many PIE related errors as possible
otherwise it's hard to analyze statuses of parasite/restorer
and the C/R process.

At least warning for logs should be produced or even C/R stopped.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-04 12:39:04 -08:00