2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00
Commit Graph

1929 Commits

Author SHA1 Message Date
Cyrill Gorcunov
0105e543a7 tty: Dump a hanging up terminal
If we've met a hanging up terminal we can escape
lot of work but dump a minimum information needed
for restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:44 +04:00
Cyrill Gorcunov
07aa668282 tty: Squash tty_get_sid, tty_get_pgrp into tty_get_sid_pgrp
This patch squashes tty_get_sid, tty_get_pgrp into
one tty_get_sid_pgrp helper (which allows to detect
if dumping terminal is hanging up, the real use of
this ability will be addressed in next patch).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:42 +04:00
Cyrill Gorcunov
978cecd629 tty: Make termios and winsize being optional params
The dangling slave peers might have no data associate
with them if master peer is closed and link is hanging
up. Thus make this parameters optional to not blow the
image with data which never will be used.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:41 +04:00
Andrey Vagin
52a2c9fd77 restorer: unify log functions
Add ability to use the same macros in restorer code.
In the future we will add ability to show arguments like printf.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 15:14:11 +04:00
Pavel Emelyanov
667953c00f restorer: Don't memcpy restorer blob in each task on restore
Instead -- mmap it once in root task and then mremap it later.
No mremap of original restorer can be done, since in that case
the restorer vma would be tied to crtools binary which in turn
will make set-exe-file prctl to fail with EBUSY.

Note -- after mremap the original vmas list becomes non relevant,
but it's OK. Only new holes appear inside which is OK for munmap.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 14:51:40 +04:00
Pavel Emelyanov
80d5fb285f restorer: Mmap restorer blob separately from the rest
This will avoid exec bit on restorer args and will make
it possible for shared restorer eventually.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 04:10:48 +04:00
Pavel Emelyanov
63ce82e7f6 restore: Sanitize restorer code + args layout
There was a strange thing -- task args size is aligned, but when
threads args ptr is get this alignment was lost. Fix this and make
all the bufs page-aligned.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 03:01:48 +04:00
Pavel Emelyanov
5a469e1894 restorer: Lost tgt vmas lenght in restorer memory blob hinting
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 02:56:14 +04:00
Pavel Emelyanov
845f3ee973 fd: Indirect fd opening states engine
Put the states into in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:34:37 +04:00
Pavel Emelyanov
1ea03bf80c fd: Relax file master checking in open and post_open
pid == pid && fd == fd equals fle == fle :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:21:14 +04:00
Pavel Emelyanov
cc41192f10 fd: Standartize arguments for fd opening stages handlers
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:17:57 +04:00
Pavel Emelyanov
b0502e4fe8 fd: Split fd opening and serving out routines
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:08:39 +04:00
Konstantin Khlebnikov
ae4796d025 zdtm: new testcase for unhashed proc entries
Testcase: fork child, chdir into /proc/$pid and kill child.

test for http://bugzilla.openvz.org/show_bug.cgi?id=2315

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Wagin <avagin@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 16:09:40 +04:00
Andrey Vagin
e628b63b17 zdtm: close an external tty
Redirect standard descriptors of a test init process in to the log file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 16:09:13 +04:00
Andrey Vagin
499e4486f5 zdtm: run test in a new session
It was lost for tests which executed in a new namespaces.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 16:08:39 +04:00
Andrey Vagin
0e4ec77612 zdtm: check restore of TCP connections (v2)
The test creates two processes.
A first process creates a tcp server, a second one connects to it.
The first process is dumped and restored.
Then the test checks that the TCP connection is alive.

v2: fix compilation :)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:56:30 +04:00
Andrey Vagin
689317bf4e zdtm: add a set of function for creating a tcp connection
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:55:08 +04:00
Cyrill Gorcunov
0910b72b3d tty: Use is_service_fd where appropriate
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:45:14 +04:00
Cyrill Gorcunov
45cc85eea4 Speed up service-fd retrieval
We're using get_service_fd in file engine,
better to make it fast. This patch caches
the limits system provides us, instead of
calling getrlimit() every time.

This patch introduces is_service_fd helper
which will be used instead of get_service_fd
where it make sense.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:45:06 +04:00
Pavel Emelyanov
b354a09cd7 rst: Brush up shared resources collection
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:11:33 +04:00
Pavel Emelyanov
ccce9fed2a tty: Brush up ctl tty preparation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:09:05 +04:00
Pavel Emelyanov
1838bee1be tty: Remove unused constants from header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:07:34 +04:00
Cyrill Gorcunov
682b9d672c app-test: check screen application
Add test for screen c/r.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:03:01 +04:00
Cyrill Gorcunov
8895729906 zdtm: Add pty04 test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:02:53 +04:00
Cyrill Gorcunov
1603f88836 zdtm: Add pty03 test
Non-opened control terminal

* Set a control terminal
* Close a file descriptor on it
* Dump/restore
* Open the control terminal (/dev/tty)
* Check, that it connected to the master end

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:02:46 +04:00
Cyrill Gorcunov
bc962a28d2 zdtm: Add pty02 test
The test is tricky -- it opens master in task 1
and dup it in task 2, then close in task 1 and
do C/R.

Thus we need to setup SID of master terminal
somehow in children, which usually fails in
currnt tty restore implementation.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:02:39 +04:00
Cyrill Gorcunov
1a41fcfc21 zdtm: Add pty01 test
Two slaves on same pty.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:02:32 +04:00
Cyrill Gorcunov
20d6762d93 tty: Add restoration of controlling terminal v4
The idea behind is pretty simple -- once we find
that there is a controlling terminal present we
do call ioctl on appropriate /dev/pts/N.

This is done in a bit unusuall manner. When we
find that there is a controling terminal present
we do create an additional FdinfoEntry for it
with object id taken from existing master peer.

The file engine stack this new FdinfoEntry on
fd_info_head head list. Thus we will have at
least two entries on this list. One for real
Fdinfo associated with master peer and one for
our new generated Fdfinfo entry, it depends on
pid which one become a file master.

Finally we do use post_open_fd hook in our
tty code which allows us to open controlling
terminal and yield proper ioctl on it.

v2:
 - restore control terminals via service fd,
   still need to speedup service fd retrieval.

v3:
 - use prepare_ctl_tty() helper to generate
   control terminal fdinfo entry

v4:
 - use post_open_fd

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:58 +04:00
Cyrill Gorcunov
d5dfab7745 check: Add check_tty
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:56 +04:00
Cyrill Gorcunov
a365befaea tty: Add show method
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:55 +04:00
Cyrill Gorcunov
89a7a45d37 tty: Add checkpoint/restore for unix terminals v6
Usually the PTYs represent a pair of links -- master peer and slave
peer. Master peer must be opened before slave. Internally, when kernel
creates master peer it also generates a slave interface in a form of
/dev/pts/N, where N is that named pty "index". Master/slave connection
unambiguously identified by this index.

Still, one master can carry multiple slaves -- for example a user opens
one master via /dev/ptmx and appropriate /dev/pts/N in sequence.
The result will be the following

master
`- slave 1
`- slave 2

both slave will have same master index but different file descriptors.
Still inside the kernel pty parameters are same for both slaves. Thus
only one slave parameters should be restored, there is no need to carry
all parameters for every slave peer we've found.

Not yet addressed problems:

- At moment of restore the master peer might be already closed for
  any reason so to resolve such problem we need to open a fake master
  peer with proper index and hook a slave on it, then we close
  master peer.

- Need to figure out how to deal with ttys which have some
  data in buffers not yet flushed, at moment this data will
  be simply lost during c/r

- Need to restore control terminals

- Need to fetch tty flags such as exclusive/packet-mode,
  this can't be done without kernel patching

[ avagin@:
   - ideas on contol terminals restore
   - overall code redesign and simplification
]

v4:
 - drop redundant pid from dump_chrdev
 - make sure optional fown is passed on regular ptys
 - add a comments about zeroifying termios
 - get rid of redundant empty line in files.c

v5 (by avagin@):
 - complete rework of tty image format, now we have
   two files -- tty.img and tty-info.img. The idea
   behind to reduce data being stored.

v6 (by xemul@):
 - packet mode should be set to true in image,
   until properly fetched from the kernel
 - verify image data on retrieval

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:54 +04:00
Cyrill Gorcunov
5340807b87 Add separate list for slave tty fds on restore v2
When we will be restoring ttys we need that restore
procedure for master peers will be yielded earlier
than for slave peers due to ttys specifics. With this
commit we introduce @tty_slaves list which will allow
us to order tty file restore procesure.

Because we need to fetch which list to be used depending
on tty type this patch extend select_ps_list with fdinfo_list_entry
parameter.

v2 (by xemul@):
 - make sure the epoll list is still last

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:52 +04:00
Andrey Vagin
e3afdd0f29 tmpfs: replace all short tar options on long analogs
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 18:34:19 +04:00
Pavel Emelyanov
93de669270 proc: Don't report error in case fdinfo for epoll fd is empty
This is normal situation -- eventpoll fd may have no fds attached
thus resulting in empty fdinfo file. Report OK in that case.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:55:15 +04:00
Andrey Vagin
278d83af20 eventpoll: popullate eventfd in post_open()
Otherwise a transport fd may be added to eventfd...

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:50:49 +04:00
Andrey Vagin
403dcb9de5 files: place the state POST_CREATE after the state RECV
It will be used for restoring epollfd.
Currently a transport fd may be added to epollfd.
epollfd should be populated, when all descriptors were already received.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:50:22 +04:00
Andrey Vagin
ca567e76c3 sk-unix: add a peer only if it's not in a list yet
I tried to fix that by:
commit bc2ac71c1a
Author: Andrey Vagin <avagin@openvz.org>
Date:   Wed Sep 12 15:16:39 2012 +0400

    sk-unix: don't add a socket in a second time

but made a mistake and now a peer would be added only if it's in a list.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:49:36 +04:00
Andrey Vagin
3c51808f1a zdtm: make several connections to a file dgram socket
Before we checked only one connection.
With this patch the test reproduces a bug:

Error (sk-unix.c:395): BUG at sk-unix.c:395

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 15:16:41 +04:00
Andrey Vagin
bc2ac71c1a sk-unix: don't add a socket in a second time
A socket can be added in a list two times, if two other sockets
are connected to it.

This patch fixes a problem:
    Error (sk-unix.c:395): BUG at sk-unix.c:395

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 15:16:39 +04:00
Andrey Vagin
0c72ab18e0 sk-unix: add more information messages
* A message about external sockets is printed before any action.
* Add a message, when a peer is added in a list of sockets.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 15:16:21 +04:00
Konstantin Khlebnikov
1d6f3cce98 zdtm: don't start state-tests on global stop
$ make cleanout stop
rm -f -r *.pid *.out* *.test* *.state
./conntracks --statefile=conntracks.state --outfile=conntracks.out start
make: *** [conntracks.state] Error 1

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:38:01 +04:00
Konstantin Khlebnikov
1ca043ea1a zdtm: fix bashisms
`< $FILE` isn't posix compatible and doesn't work in dash

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:37:51 +04:00
Konstantin Khlebnikov
80a8cb80f2 zdtm.sh: fix bashisms
fix obvious bashisms to make script more portable

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:37:36 +04:00
Konstantin Khlebnikov
fd735d8be3 zdtm: fix struct tpacket_req3 redeclaration
Linux has it since v3.2

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -I../../lib   packet_sock.c ../../lib/libzdtmtst.a   -o packet_sock
packet_sock.c:70:8: error: redefinition of ‘struct tpacket_req3’
In file included from packet_sock.c:23:0:
/usr/include/linux/if_packet.h:245:8: note: originally defined here

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:41 +04:00
Konstantin Khlebnikov
cfa2150490 zdtm: fix comilation for non-constant PAGE_SIZE
On some systems PAGE_SIZE is declared as sysconf(_SC_PAGESIZE) in <sys/user.h>
this is non-constant expression, so it cannot be used in type declarations.

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0   -c -o ns.o ns.c
ns.c:124:7: error: variably modified ‘stack’ at file scope

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:30 +04:00
Konstantin Khlebnikov
dccb15cc0f zdtm: fix compilation in test_msg()
cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0   -c -o msg.o msg.c
msg.c: In function ‘test_msg’:
msg.c:40:6: error: variable ‘len’ set but not used [-Werror=unused-but-set-variable]

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:21 +04:00
Pavel Emelyanov
720cab0bd8 fd: Sanitize open_fd with send_fd_to_self helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:27:21 +04:00
Pavel Emelyanov
8cc9477d46 fd: Rename tmp to ret in open_fd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:20:21 +04:00
Pavel Emelyanov
97dba0eb8f fd: Fast path post open
Check for post_open callback presense before any other checks.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:07:21 +04:00
Pavel Emelyanov
84d1ffb986 fd: Move rst fd list iteration into helper
Same again -- for code to be cleaner.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 21:47:14 +04:00