2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00
Commit Graph

1243 Commits

Author SHA1 Message Date
Pavel Emelyanov
aec30b34db crtools: Add long options
By now equip all the short options with respective long one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 14:23:05 +04:00
Pavel Emelyanov
ed7586a7ad crtools: Rewrite options parsing via while
This avoids two duplicate lines.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 14:14:41 +04:00
Cyrill Gorcunov
90ae972b9a files: Sanitize message on fd restoring
The message "Got fd for %d" is non-informative,
change it to "Restoring fd %d" since that is
what function does.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:37:38 +04:00
Cyrill Gorcunov
6e7c9ea84d util: Extend reopen_fd_as_safe
Our loggin engine prints file:line only at invoke point,
so it's unable to see where exactly reopen_fd_as_safe is
failed.

With this patch the output is more human readable

 | Error (util.c:96): fd 7 already in use (called at files.c:359)

Ideally we need full backtrace here, but it's different task.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:35:51 +04:00
Kinsbursky Stanislav
231db3f80d output: add "0x" to hex prints manually
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:34:01 +04:00
Kinsbursky Stanislav
35eedb5f1f output: add "0x" to hex prints using sed
Command below was executed several times:

sed 's/\(pr_.*[^%,x,X]\)\(\%[0-9,l,L]*x\)/\10x\2/g' -i *.c

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:33:35 +04:00
Cyrill Gorcunov
62094fa851 sockets: Drop one-line alignment block
Make sense in multiline cases only.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 10:03:03 +04:00
Cyrill Gorcunov
090513d5fd restorer: Make sure the protection on code/data mm areas do fit the kernel requirements
When set up mm::code/data addresses the kernel expects
the correspond VMAs to have predefined protection, but
task might have dropped or mprotected those VMAs at moment
of checkpoint. So just setup fake VMAs, call prctl and
munmap them immediately.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 19:08:04 +04:00
Cyrill Gorcunov
7657c34ab7 restore: Temporary comment out exit's on sid/pgid mismatch
Util we have kernel support.
[ xemul: MySQL uses runaway pgid and sid and we cannot restore it
  gracefully with exiting API :( Byt MySQL seem not to care about
  pgid and sid change after restore, so ignore this for a while ]

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 19:06:35 +04:00
Pavel Emelyanov
1708c747d1 magics: Move them one tab right
To line the constants up.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 18:02:50 +04:00
Cyrill Gorcunov
6b391522df sockets: Print sockets ino and peer with %x format
Some ino/peers are printed with %d, some with %x,
get rid of it and print all in %x.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 18:01:16 +04:00
Pavel Emelyanov
fb27ed4e68 zdtm: Tests for testing completely unlinked files
This includes existing test and a new one, checking that
unlinked hardlinks are handled properly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 17:57:35 +04:00
Pavel Emelyanov
a1ccfb9297 files: Support dumping/restoring of completely unlinked files
Completely unlinked file is the one with n_link count being zero.
Such files only allow to read their contents and carry with us.

In order to dump this thing I introduce the "path remap" technology.
For reg file a remapping entry is dumped which describes, that at
restore stage before opening a regfile->path this path should be
linked to some other name and then (after open) unlinked.

For completely unlinked files the remap path would be a path to
a "ghost" file, i.e. a file which is created only at the time of
restore and which is removed completely at the end of it.

Partially unlinked files (i.e. those having n_link != 0, but a
path by which we see them in someone's fd is not accessible) should
be handled in another way.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 17:54:36 +04:00
Pavel Emelyanov
14451ed3ce util: Add fn for copying file from one fd to another
Will be required to dump completely unlinked files.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 17:52:35 +04:00
Pavel Emelyanov
09d9598074 sock: Add udp-lite sockets support
This is trivial. Just copy-n-paste pieces from the udp dumping
and restoring code. The zdtm test is also a compy of the _udp
test with respecitve changes.

Reuired for httpd, this one uses udplite sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 10:42:30 +04:00
Cyrill Gorcunov
b9104ebc97 sockets: Fix potential NULL dereference
In case if unix socket was not found don't call for container_of.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 00:03:35 +04:00
Pavel Emelyanov
81c72ea640 restore: Remove unused struct shmem_id and variables
Most likely they left from Andrey's shmem rework.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:46:57 +04:00
Pavel Emelyanov
0e51036d16 show: Move extern print_data declaration from sockets.c to header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:33:09 +04:00
Pavel Emelyanov
c96b201700 sockets: Mark open_unix_sk static
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:32:16 +04:00
Cyrill Gorcunov
ccdca9e3d1 dump: Add missing new lines
Otherwise output looks like

Dumping core (pid: 16953)
----------------------------------------
Dumping GP/FPU registers ... OK
Obtainting personality ... OK
Obtainting task auvx ... Dumping path for 1 fd via self 19 [/home/crtools/test/legacy/test-inotify]
Dumping header ... ----------------------------------------

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:22:06 +04:00
Pavel Emelyanov
f379e2ccf5 test: Add tar + bzip2 testsuite
Generate a pseudorandom tree of files, run tar cjf on it
to create referenced tarball, then run the same again on
the background, wait for a while, then checkpoint and restore
it and compare that two tarballs do not differ.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:20:15 +04:00
Cyrill Gorcunov
794d3fba40 zdtm: Extend file_own test for both pipe ends
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 14:32:02 +04:00
Cyrill Gorcunov
2d19a8750e pipes: Set fowners for both pipe ends
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 14:31:28 +04:00
Cyrill Gorcunov
6177c92bac pipes: Drop unused find_pipe(int id)
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 14:19:06 +04:00
Pavel Emelyanov
1a1a1861dd tests: Add new "real-life" test suit
The intention is to put here tests, that check how real apps
work. Initially I test that make -j4 works. This test is very
basic (uses sleep to wait for make to fork everybody) and a
syntetic .c file (quite big though).

Extend and use.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 13:33:24 +04:00
Cyrill Gorcunov
956d28bb65 zdtm: Extend file_own test for sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:31:58 +04:00
Cyrill Gorcunov
a8840ba721 fowners: Add checkpoint/restore for sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:31:33 +04:00
Cyrill Gorcunov
df6d5cfb23 zdtm: Add file_own test case
Tests for pipes fowners checkpoint/restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:29:25 +04:00
Cyrill Gorcunov
318535db97 fowners: Restore for regular files and pipes
The base idea is trivial, once file descriptor
created the owner is read and set up.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:28:51 +04:00
Cyrill Gorcunov
44492851e1 fowners: Add regular files/pipes owners dumping
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:28:34 +04:00
Cyrill Gorcunov
ff3471f726 fowners: Prepare ground for dump and restore
Just show implemented and stubs added to image
(regular file and pipes).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:28:15 +04:00
Cyrill Gorcunov
d29f3bc02f types: Add F_GETOWNER_UIDS opcode
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:27:54 +04:00
Pavel Emelyanov
b53c42a50b zdtm: Test for pgids and sids
If I'm not mistaken this covers all the if-s in the
restore_pgid and restore_sid code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:13:43 +04:00
Pavel Emelyanov
814bd5d321 xids: Dump and restore tasks' pgid and sid
This is preriquisity for terminals handling and just a good
practice to save and restore everything we can :)

Not all combinations are supported. All the problems we still
have come from the inability to attach to group/session with
ID no tasks own as its PID.

This can be workarounded by fork()-ing this pid temporarily,
but we'd rather think in the direction of modifying the kernel
to give us direct syscall for this (oh my...)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:11:41 +04:00
Pavel Emelyanov
6f67bb8fc3 xids: Save pgid and sid on pstree_Item and pstree_entry
I store them on _entry since sids can only be inherited or
set to current's pid. Thus the best we can do it restore sids
at fork time, thus save them in the image we use to fork.

Maybe when we submit patches that will give us ability to set
arbitrary pgid and sid we'll change this, but this is in the
future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:10:09 +04:00
Pavel Emelyanov
6ed9f87269 proc: Make small stat parsing read pgid and sid
They are just two next in this file, so extend. This is
required for pgid/sid early read, see next patches for
details.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:09:12 +04:00
Pavel Emelyanov
2a0c526b6d dump: Save pstree_item's parent on item, not ppid
This is trivial change, but is required to check for pgid/sid
are in 'restorable' state, see for respective patch/code for
details.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:07:47 +04:00
Pavel Emelyanov
b17c49aa99 rst: Wait till everyone completes forking on restore
New stage CR_STATE_FORKING. This is required to restore pgids
properly -- we need to make sure a task with pid whose pgid we
are about to enter is alive. And this task is not necesserily
our parent, thus wait for everyone to appear.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:06:36 +04:00
Pavel Emelyanov
b63451e58d log: Open log file with O_APPEND
Otherwise multiple writers can screw each-other's messages.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:06:00 +04:00
Pavel Emelyanov
1e6d32276a parasite: Cure task in case any dump failed while infected
Wile the task is infected we cannot just detach from it and go away. The victim will die after this.
So, call the parasite_cure_seized on any error handing between infect and cure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 15:25:03 +04:00
Pavel Emelyanov
1e9ccd2bbd dump: Don't kill tasks after failed dump
This is not very good practice :) Just leave them in the state they've been to before
dumping. Plz note, that tasks segfault for some reason after unseizeing, but this is
another story.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 15:17:26 +04:00
Pavel Emelyanov
13ee53a098 sockets: Save and restore fd flags for sockets
For regfiles this is done at open() time, for pipes thit is done with fcntl. Use
the same fcntl approach for sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 13:20:03 +04:00
Cyrill Gorcunov
827f1a2f0b files: Don't call for run_unix_connections if there error happened earlier
It doesn't make sense to try to connect sockets if error
happened previously.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:49 +04:00
Cyrill Gorcunov
611343a50c files: Print the state of files restoring transition
It's confusing to see the output like

 | Got fd for 3
 | Got fd for 3

Better to point what is going on

 | Got fd for 3 (state -> 0)
 | Got fd for 3 (state -> 1)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:29 +04:00
Cyrill Gorcunov
a83ad7b813 files: Drop redundant lseek in prepare_fds
No need to obtain MAGIC_OFFSET from current position,
the files have predefined structure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:12 +04:00
Pavel Emelyanov
b0aa868d47 zdtm: Add test for close-on-exec bits
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:38:03 +04:00
Pavel Emelyanov
05e3c4d2c9 fd: Handle close-on-exec bits
This bit is not per-file, but per-fd, thus put it on the fdinfo_entry.
Draing these bits from parasite together with the fds themselves, save
into image and restore with fcntl F_SETFD cmd where applicable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:36:59 +04:00
Pavel Emelyanov
30224abcb6 util-net: Make send/recv fds carry fd flags in message
The flags are only one bit in the kernel (close-on-exec, all the rest are not per-fd, but per-file),
but for simplicity I save it in a char field.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:36:13 +04:00
Pavel Emelyanov
e8cdf57f40 syscall: Add fcntl syscall and F_GETFD cmd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:35:54 +04:00
Pavel Emelyanov
f999b8cfb5 dump: Rename fd dumping functions
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:17:26 +04:00