2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

4636 Commits

Author SHA1 Message Date
Andrey Vagin
232cb4b34b parasite: remove useless check from parasite_stop_on_syscall() (v2)
We have the same check a few lines above.

v2: fix the subject
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-18 20:11:08 +04:00
Andrey Vagin
7fa98a30bc mount: handle a circular reference in mount tree
$ cat /proc/self/mountinfo
...
1 1 0:2 / / rw - rootfs rootfs rw,size=373396k,nr_inodes=93349
...

You can see that mnt_id and parent_mnt_id are equals here.
This patch interpretes this case as a root mount in a tree.

0'th mount is rootfs, which is mounted in init_mount_tree().

We don't see it in cases when system makes chroot, because of

static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
	...
	/* mountpoints outside of chroot jail will give SEQ_SKIP on this */
	err = seq_path_root(m, &mnt_path, &root, " \t\n\\");

Cc: beproject criu <beprojectcriu@gmail.com>
Cc: Christopher Covington <cov@codeaurora.org>
Reported-by: beproject criu <beprojectcriu@gmail.com>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-16 23:17:55 +04:00
Pavel Emelyanov
4eec4c6ea1 rst: Don't allocate PATH_MAX for /proc/self realink
Pid is 10 chars maximum.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-16 23:16:18 +04:00
Cyrill Gorcunov
b99b76b045 cg: proc_parse -- Don't compare cgroup paths
When we compare sets in cg_set_compare() we presume that controller
names are properly sorted but because of use of strcmp(cc->path, path)
it's not true. In particular in case if there are two same sets which
differ in paths only

(00.126812) cg:  `- New css ID 2
(00.127051) cg:     `- [memory] -> [/vz-1]
(00.127079) cg:     `- [name=systemd] -> [/vz-1]
(00.127108) cg:     `- [net_cls] -> [/vz-1]

(00.239829) cg:  `- New css ID 3
(00.240067) cg:     `- [memory] -> [/vz-1]
(00.240096) cg:     `- [net_cls] -> [/vz-1]
(00.240154) cg:     `- [name=systemd] -> [/vz-1/system.slice/dbus.service]

we currently refuse to dump such configuretion. Thus remove
path comparision from the first place.

CC: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-16 23:14:47 +04:00
Andrey Vagin
aadc309a4f mount: validate mounts only once on dump (v3)
mntinfo contains mounts from all namespaces, so we can validate it only
once after collecting mounts.

v2: add a fake comment about goto
v3: add a real comment about goto
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-15 16:15:50 +04:00
Tycho Andersen
32b032b61c service: service should compile on Ubuntu 14.04
I'm not quite sure what the difference is (I have gcc 4.8, but there are
probably also header differences), but when I compile the service on 14.04 I
get:

  CC       cr-service.o
cr-service.c: In function ‘start_page_server_req’:
cr-service.c:536:8: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   write(start_pipe[1], &ret, sizeof(ret));
        ^
cr-service.c:544:6: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result]
  read(start_pipe[0], &ret, sizeof(ret));
      ^

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Tested-by: https://travis-ci.org/avagin/criu/builds/34990769
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-12 14:06:04 +04:00
Konstantin Neumoin
7493eef982 zdtm: fix msg reporting
avoid err() for regular msg reporting

Acked-by: Andrew Vagin <avagin@parallels.com>

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-12 14:02:03 +04:00
Andrey Vagin
7576898243 zdtm/mountpoints: add "unknown" options to reproduce the previous bug
tmpfs has the "size" option, which is not standard.

Execute zdtm/live/static/mountpoints
./mountpoints --pidfile=mountpoints.pid --outfile=mountpoints.out
Dump 2737
WARNING: mountpoints returned 1 and left running for debug needs
Test: zdtm/live/static/mountpoints, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/mountpoints, Namespace:
Dump log   : /root/git/criu/test/dump/static/mountpoints/2737/1/dump.log
--------------------------------- grep Error ---------------------------------
(00.146444) Error (mount.c:399): Two shared mounts 50, 67 have different sets of children
(00.146460) Error (mount.c:402): 67:./zdtm_mpts/dev/share-1 doesn't have a proper point for 54:./zdtm_mpts/dev/share-3/test.mnt.share
(00.146820) Error (cr-dump.c:1921): Dumping FAILED.
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-10 18:33:10 +04:00
Andrey Vagin
f88d72d0bd mount: strip options for all mounts
Currently we stript options only one of brothers, but
mount_equal() thinks that two brothers should have the same options.

Execute zdtm/live/static/mountpoints
./mountpoints --pidfile=mountpoints.pid --outfile=mountpoints.out
Dump 2737
WARNING: mountpoints returned 1 and left running for debug needs
Test: zdtm/live/static/mountpoints, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/mountpoints, Namespace:
Dump log   : /root/git/criu/test/dump/static/mountpoints/2737/1/dump.log
--------------------------------- grep Error ---------------------------------
(00.146444) Error (mount.c:399): Two shared mounts 50, 67 have different sets of children
(00.146460) Error (mount.c:402): 67:./zdtm_mpts/dev/share-1 doesn't have a proper point for 54:./zdtm_mpts/dev/share-3/test.mnt.share
(00.146820) Error (cr-dump.c:1921): Dumping FAILED.
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

Reported-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-10 18:33:08 +04:00
Andrey Vagin
cb738520e3 mount: don't skip checks in validate_mounts()
"continue" is called by mistake, so we skip a few checks for shared
mounts without siblings.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-10 18:32:20 +04:00
Pavel Emelyanov
53957fadc3 restore: Introduce the --restore-sibling option
We have a slight mess with how criu restores root task.
Right now we have the following options.

1) CLI
	a) Usually
	task calling criu
	 `- criu
	     `- root restored task

	b) when --restore-detached AND root has pdeath_sig

	task calling criu
	 `- criu
	 `- root restored task

2) Library/SWRK
	task using lib/swrk
	 `- criu
	 `- root restored task

3) Standalone service
	a) Usually
	service
	 `- service sub task
	     `- root restored task

	b) when root has pdeath_sig
	criu service
	 `- criu sub task
	 `- root restored task

It would be better is CRIU always restored the root task as sibling,
but we have 3 constraints:

First, the case 1.a is kept for zdtm to run tests in pid namespaces
on 3.11, which in turn doesn't allow CLONE_PARENT | CLONE_NEWPID.

Second, CLI w/o --restore-detach waits for the restored task to die and
this behavior can be "expected" already.

Third, in case of standalone service tasks shouldn't become service's
children.

And I have one "plan". The p.haul project while live migrating tasks
on destination node starts a service, which uses library/swrk mode. In
this case the restored processes become p.haul service's kids which is
also not great.

That said, here's the option called --restore-child that pairs the
--restore-detach like this:

* detached AND child:

task
 `- criu restore (exits at the end)
 `- root task

The root task will become task's child.
This will be default to library/swrk.
This is what LXC needs.

* detach AND !child

task
 `- criu restore (exits at the end)
     `- root task

The root task will get re-parented to init.
This will be compatible with 1.3.
This will be default to standalone service and
to my wish with the p.haul case.

* !detach AND child

task
 `- criu restore (waits for root task to die)
 `- root task

This should be deprecated, so that criu restore doesn't mess
 with task <-> root task signalling.

* !detach AND !child

task
 `- criu restore (waits for root task to die)
     `- root task

This is how plain criu restore works now.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
2014-09-10 18:30:30 +04:00
Tycho Andersen
1ff2500b9e restore: use root_as_sibling only after defining it
root_as_sibling was used in criu_signals_setup(), but was only defined later
(when forking the root task for the first time). This meant that the
SA_NOCLDSTOP was never masked off, which meant SIGCHLD was never delivered
after ptracing the root task. Thus, when the a child of the root task died
(e.g. from cr_system), the root task sat in PTRACE_STOP, and the restore task
never PTRACE_CONT'd, resulting in a deadlock.

Instead, we only unmask SA_NOCLDSTOP right before we PTRACE_SEIZE, after the
value is defined.

v2: re-work the condition for CLONE_PARENT
v3: move unmasking of SA_NOCLDSTOP to restore_root_task
v4: keep all the comments in the original code

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-10 14:53:31 +04:00
Pavel Emelyanov
f45060e132 scripts: Fix path assignment
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-09 22:07:57 +04:00
Saied Kazemi
bd8b5dd53c Add a convenience shell script for Docker container C/R
Since the command line for checkpointing and restoring Docker containers
is very long and there are some manual steps involved before restoring
a container, it's much easier to use a shell script to automate the work.

One would simply do:

$ sudo docker_cr.sh -c
$ sudo docker_cr.sh -r

Signed-off-by: Saied Kazemi <saied@google.com>
Acked-by: Filipe Brandenburger <filbranden@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-09 16:08:22 +04:00
Andrey Vagin
5fcebf2d7e zdtm/inotify00: fix expected sets of events
zdtm.sh with zero iterations of dumping/restoring checks correctness of
tests.

$ bash test/zdtm.sh -i 0 zdtm/inotify00
Output file: /root/git/orig/criu/test/zdtm/live/static/inotify00.out
------------------------------------------------------------------------------
19:16:29.601:  6905: 	unlink 02       : event      0x200 -> IN_DELETE
19:16:29.602:  6905: 	unlink 02       : event      0x200 -> IN_DELETE
19:16:29.602:  6905: 	unlink 02       : event        0x8 -> IN_CLOSE_WRITE
19:16:29.602:  6905: 	unlink 02       : event        0x8 -> IN_CLOSE_WRITE
19:16:29.602:  6905: 	unlink 02       : event      0x400 -> IN_DELETE_SELF
19:16:29.602:  6905: 	unlink 02       : event     0x8000 -> IN_IGNORED
19:16:29.602:  6905: 	unlink 02       : read  6 events
19:16:29.614:  6905: 	after           : event        0x8 -> IN_CLOSE_WRITE
19:16:29.614:  6905: 	after           : read  1 events
19:16:29.614:  6905: FAIL: inotify00.c:217: Unhandled events in emask 0x200 -> IN_DELETE (errno = 11 (Resource temporarily unavailable))
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

This patch removes logic about linked files, because it's useless.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 19:41:47 +04:00
Andrew Vagin
e248e65cc9 locks: fix up a device returned by stat() for btrfs (v4)
BTRFS returns subvolume dev-id instead of superblock dev-id,
in such case return device obtained from mountinfo (ie subvolume0).

v2: fix up devices only for btrfs files.
v3: use phys_stat_dev_match instead of phys_stat_resolve_dev
v4: fix cosmetic whims

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 16:02:40 +04:00
Konstantin Neumoin
61dbc97643 zdtm: fix /proc/lock parsing
11: POSIX  ADVISORY  WRITE 1 b6:a4111:136512 0 EOF
Acked-by: Andrew Vagin <avagin@parallels.com>

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 16:01:39 +04:00
Cyrill Gorcunov
11d8642a20 fsnotify: Proceed dumping even if queue has data
It turns out that we can't be too strict about
queued events -- criu itself generates a number
of them and there is no clear way yet how to resolve
this situation. So defer "strict" mode for now
but print a warning.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 16:00:46 +04:00
Pavel Emelyanov
b47b0201f3 page-server: Don't setup options in parent task
When service starts page server all the preparations (log, wdir, img dir, etc.)
happen in parent task, then we fork page server.

This is OK for now, but when we will serve several requests per connection, all
these resources would be leaked in parent.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 13:49:54 +04:00
Pavel Emelyanov
66170c6bd7 service: Allow to server more requests after page-server start
The problem with several requests is that criu leaks resources after
doing dump/restore. It's OK since process exits anyway, but for
multy requests per connection it's better to audit this thing.

For now -- allow to do requests after the page-server-start one only.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 13:49:20 +04:00
Pavel Emelyanov
eed38acc72 service: Do one exit point from cr_service_work
That's preparation to "several requests per connection" patch.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 13:49:19 +04:00
Pavel Emelyanov
76017ec5a4 scripts: Use numeric action val in RPC notifications
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 13:48:27 +04:00
Pavel Emelyanov
17d44de9af scripts: Use numeric script names
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 13:48:26 +04:00
Pavel Emelyanov
069bdd9674 scripts: Move scripts code into separate sources
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 13:48:21 +04:00
Andrey Vagin
5c26570747 cgroups: allow to execute fini_cgroups a few times
It is called from prepare_cgroup_sfd() and cr_restore_tasks().

+ criu restore --file-locks --tcp-established --evasive-devices --link-remap --root /var/lib/vz/root/101 --restore-detached --action-script /usr/local/libexec/vzctl/scripts/vps-rst-env -D /vz/dump/Dump.101 -o restore.log -vvvv --pidfile /var/lib/vzctl/vepid/101
*** Error in `criu': double free or corruption (fasttop): 0x00000000006bcd40 ***

Program terminated with signal 6, Aborted.
Missing separate debuginfos, use: debuginfo-install glibc-2.17-20.fc19.x86_64 libgcc-4.8.3-1.fc19.x86_64 protobuf-c-0.15-7.fc19.x86_64
(gdb) bt
 #0  0x00007ffff72179e9 in raise () from /lib64/libc.so.6
 #1  0x00007ffff72190f8 in abort () from /lib64/libc.so.6
 #2  0x00007ffff7257d17 in __libc_message () from /lib64/libc.so.6
 #3  0x00007ffff725f0b8 in _int_free () from /lib64/libc.so.6
 #4  0x0000000000426971 in cr_restore_tasks () at cr-restore.c:1833
 #5  0x0000000000418426 in main (argc=<optimized out>, argv=0x7fffffffeb38, envp=<optimized out>) at crtools.c:479

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-04 16:35:43 +04:00
Cyrill Gorcunov
68138cf3d1 test: inotify00 -- Rework test, v2
To show which events are coming and flush events before dump as required by new fsnotify mode.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-04 15:42:56 +04:00
Andrey Vagin
67cc8be34d zdtm: mount test cgroup controllers before executing tests
If a controller is mounted during dumping processes, criu may fail with error:
Error (cgroup.c:768): cg: Set 3 is not subset of 2

so lets create all test controllers before executing tests.

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 21:08:07 +04:00
Andrey Vagin
4be6350cfb fsnotify: don't dump fd, it is has queued evetns
Events are not dumped/restored. An idea of ignoring them isn't good.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 21:00:41 +04:00
Tycho Andersen
ae3cb4fb1f restore: open the pidfile with O_EXCL
There is a potential attack here where if someone is restoring something and
criu write the pid to a file the attacker controls, the attacker can then
re-write that to whatever pid they want. ciru should instead open the file with
O_EXCL so that the restore fails if the file exists.

We don't need O_TRUNC here since we're O_EXCL-ing the file.

Reported-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:58:24 +04:00
Cyrill Gorcunov
d6f09cd35c log: Use pr_quelled helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:56:58 +04:00
Cyrill Gorcunov
d039868f99 log: Add pr_quelled helper
If we need to check if current loglevel will suppress
our messagess (say you need to run pr_debug in a cycle)
we can use this helper to eliminate unneded calls.

Like
  if (!pr_quelled(LOG_DEBUG)) {
    ... do something specific to LOG_DEBUG ...
  }

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:56:54 +04:00
Andrey Vagin
c40eff85dc eventpoll: merge eventpoll tfd into eventpoll image
All marks are collected in a list and then they are written in
the eventpoll image as a repeated field.

This images merge reduces the amount of image files criu
generates and may simplify the fix of mentioned above issue

v2: save the original order of entries
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:51:40 +04:00
Andrey Vagin
c4a8dd17bc fsnotify: merge fanotify mark image into fanotify image (v3)
All marks are collected in a list and then they are written in
the fanotify image as a repeated field.

This images merge reduces the amount of image files criu
generates and may simplify the fix of mentioned above issue

v2: don't leak fe.mark_entry
v3: save the original order of marks
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:51:39 +04:00
Andrey Vagin
a10907a1dd fsnotify: merge inotify wd image into inotify image (v4)
All watch descriptors are collected in a list and then
they are written in inotify image as a repeated field.

This images merge reduces the amount of image files criu
generates and may simplify the fix of mentioned above issue.

v2: use free_inotify_wd_entry() instead of xfree in dump_one_inotify()
v3: don't leak ie.wd_entry
v4: save the original order of watchers
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:51:38 +04:00
Pavel Emelyanov
7058714fda service: Add ability to inherit page server socket
The swrk action is turning out to be a cool thing. We can
spawn criu with swrk action with some FD being open, then
ask for dump/pre-dump/page-server telling it that some
descriptor it needs is "out there".

This patch lets us specify that the page server communication
channel is already in criu's fdtable.

TODO: teach regular service to accept fd via service socket.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:50:12 +04:00
Cyrill Gorcunov
3146f58317 plugin: Rework plugins API, v2
Here we define new api to be used in plugins.

 - Plugin should provide a descriptor with help of
   CR_PLUGIN_REGISTER macro, or in case if plugin require
   no init/exit functions -- with CR_PLUGIN_REGISTER_DUMMY.

 - Plugin should define a plugin hook with help of
   CR_PLUGIN_REGISTER_HOOK macro.

 - Now init/exit functions of plugins takes @stage
   argument which tells plugin which stage of criu
   it's been called on dump/restore. For exit it
   also takes @ret which allows plugin to know if
   something went wrong and it needs to cleanup
   own resources.

The idea behind is to not limit plugins authors with names
of functions they might need to use for particular hook.

Such new API deprecates olds plugins structure but to keep
backward compatibility we will provide a tiny layer of
additional code to support old plugins for at least a couple
of release cycles.

For example a trivial plugin might look like

 | #include <sys/types.h>
 | #include <sys/stat.h>
 | #include <fcntl.h>
 | #include <libgen.h>
 | #include <errno.h>
 |
 | #include <sys/socket.h>
 | #include <linux/un.h>
 |
 | #include <stdio.h>
 | #include <stdlib.h>
 | #include <string.h>
 | #include <unistd.h>
 |
 | #include "criu-plugin.h"
 | #include "criu-log.h"
 |
 | static int dump_ext_file(int fd, int id)
 | {
 |	pr_info("dump_ext_file: fd %d id %d\n", fd, id);
 |	return 0;
 | }
 |
 | CR_PLUGIN_REGISTER_DUMMY("trivial")
 | CR_PLUGIN_REGISTER_HOOK(CR_PLUGIN_HOOK__DUMP_EXT_FILE, dump_ext_file)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:48:36 +04:00
Cyrill Gorcunov
b858711726 plugin: Beautify criu-plugin.h
- use custom multiline comments style
 - ending #endif comment

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:46:40 +04:00
Pavel Emelyanov
57c7826a8e locks: Check for --file-locks option when real locks are found
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 20:20:47 +04:00
Pavel Emelyanov
b6e3223a1e locks: Don't skip out-of-tree flocks
These guys may have pids that are not met in pstree.
This is not the reason for skipping those, try to
resolve flocks anyway.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:54:28 +04:00
Pavel Emelyanov
e523b371c7 test: Don't compare PIDs when searching for our locks
Criu may re-lock the lock, thus spoiling the pid, so compare
the file inode number instead.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:09:47 +04:00
Pavel Emelyanov
0a11aa1ff9 locks: When checking for lock being ours handle mand-locks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:09:45 +04:00
Pavel Emelyanov
180005645c locks: Split lock-in-fd check in a helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:09:43 +04:00
Andrey Vagin
3a6f57cbce fsnotify: fix exit code of dump_inotify_entry()
Return 0 in a success case

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:56:48 +04:00
Pavel Emelyanov
d58aafc447 dump: Don't allocate dfds in case we dump shared fdtable
After patches, that dump locks w/o dfds array, we can even
not allocate one when we don't need it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:45:29 +04:00
Pavel Emelyanov
2c765509f5 test: Check that criu's donwgrading quirk works
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:58 +04:00
Pavel Emelyanov
96e6ea5ae7 test: Check that overlapping locks work
If we open a file, lock one, fork, then close and
open the file in parent again, lock should 'slide'
to the child process anyway.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:54 +04:00
Pavel Emelyanov
92a7cf59ad test: Check that inherited flocks work
Inherited flock is the one that a task got from its parent.
In case parent closes the corresponding fd, the /proc/locks
still shows the parent pid, while the lock is owned by child.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:53 +04:00
Pavel Emelyanov
b593024dd6 test: Check that shared locks work
Shared here means that a flock is visible from two tasks -- the
owner one and its child.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:50 +04:00
Pavel Emelyanov
53537f52c8 locks: Don't dump locks in per-task manner (v3)
We have a problem with file locks (bug #2512) -- the /proc/locks
file shows the ID of lock creator, not the owner. Thus, if the
creator died, but holder is still alive, criu fails to dump the
lock held by latter task.

The proposal is to find who _might_ hold the lock by checking
for dev:inode pairs on lock vs file descriptors being dumped.
If the creator of the lock is still alive, then he will take
the priority.

One thing to note about flocks -- these belong to file entries,
not to tasks. Thus, when we meet one, we should check whether
the flock is really held by task's FD by trying to set yet
another one. In case of success -- lock really belongs to fd
we dump, in case it doesn't trylock should fail.

At the very end -- walk the list of locks and dump them all at
once, which is possible by merge of per-task file-locks images
into one global one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:46 +04:00
Pavel Emelyanov
efac9ed8b3 locks: Parse lock type earlier
Same reason as for previous patch.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:39 +04:00