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

67 Commits

Author SHA1 Message Date
Pavel Emelyanov
20e8d193e5 tty: Print very descriptive message about shell job dump
First thing people typically do with criu is run something
in shell and try to dump it. This is typicall pitfall, as
in that case we face external sid and tty problem. Print a
message on stdout about this and advice wiki page to read.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-03 09:59:17 +04:00
Andrey Vagin
dd407dd04e hdrs: minor cleaup
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-07 15:13:50 +04:00
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
1300cf4915 crtools: move all stuff about fdset in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 15:24:48 +04:00
Andrey Vagin
824403a009 crtools: create new header for servicefd stuff (v2)
v2: generate patch relative to the official git.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:43:02 +04:00
Pavel Emelyanov
b18fb09eb9 show: Replace one-line show_foo calls with args array
We have generic do_pb_show() call and tons of show_foo
routines, that just call one with proper args. Compact
the code by putting the args into array and calling
the do_pb_show() in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-24 04:00:32 +04:00
Pavel Emelyanov
84737e2796 build: Generate most of the pb-desc automatically
These contain linkage between number, data type and routines
for pb messages we write/read to/from image files. Most of them
have simple number-type-routines mapping, so introduce a generating
script for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-23 21:47:31 +04:00
Pavel Emelyanov
60e6d38868 collect: Shorten common images collecting code
Now we have a set of cinfo-s, it's possible to collect all
this stuff in a plan for-loop.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 03:52:18 +04:00
Pavel Emelyanov
64e7d2435a collect: Reduce amount of args to collect_image call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 03:27:06 +04:00
Pavel Emelyanov
9917c4fe34 rst: Compact file-descs collects a bit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 01:06:58 +04:00
Pavel Emelyanov
72ec39f10c util: Rename pie's util-net.c into util.c
Will put more things there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-29 12:43:30 +04:00
Pavel Emelyanov
d020ebb36d files: Compact the code by removing per-file dump helpers
Since *all* of them just call do_dump_gen_file with proper ops,
just call one directly. Compacts the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-06-14 00:11:08 +04:00
Pavel Emelyanov
6bf22f8c75 crtools: Get rid of on-stack cr_options
We have global instance of them, that's enough.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-28 21:11:13 +04:00
Cyrill Gorcunov
01c9ec6184 tty: Don't try to restore a group on inherited terminal if session leader present
In case if we are migrating a session leader task with a solely
slave peer we should not try to restore a group on the terminal
but rather simply inherit it, because a session of the group of
the inherited terminal is not the same as a session of our leader
thus kernel refuse to set any different group here.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-07 22:35:33 +04:00
Cyrill Gorcunov
19de6865c4 tty: Use separate tty_info::inherit member to track ttys being borrowed from a parent
This is easier for debugging, the former SID/PGID remains untouched
and printed out in logs.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-07 22:35:31 +04:00
Cyrill Gorcunov
921dbf23de Don't use \Newline in pr_perror
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-02 22:44:24 +04:00
Kir Kolyshkin
41c7ca8218 Fix typos in comments
This is less useful than fixing typos in output messages, but anyway.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:46 +04:00
Kir Kolyshkin
d90d4b1b88 Fix typos in log messages
Someone has to do it, right?..

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:25 +04:00
Pavel Emelyanov
25ef419982 tty: More descriptive log message about --shell-job requirement
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 20:11:00 +04:00
Andrey Vagin
967ca651a8 tty: restore sid on master points only (v2)
If a master point has sid, it doesn't mean, that all slave points
will have sid. Look at tty03 for example:

  PID   SID TT       COMMAND
26748 26748 ?        tty03
26749 26749 pts/2     \_ tty03
26750 26750 ?             \_ tty03

The second process has not a file descriptor for the ctl tty,
but this tty is opened in tty03.

v2: If a slave point with sid has not a master point, the option
--shell-job must be set and sid isn't restored for such terminals.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 23:01:51 +04:00
Andrey Vagin
ea767143f1 tty: require stdin to be a terminal only if shell_job is set
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-22 22:45:31 +04:00
Andrey Vagin
4ea6214391 crtools: add ability to create and close a service fd (v3)
A service fd should be created, otherwise get_service_fd returns -1.

This patch removes this functionality from other subsystems and
allows to clone service descriptors.

v2: rename open_service_fd to install_service_fd
v3: two patches were merged for bisecting

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:37 +04:00
Andrey Vagin
0fc129a121 files: pass a file descriptor on an fdinfo image instead of cr_fdset
Currently fdinfo dumps for each task, so CR_FD_FDINFO is in cr_fdset.
A few tasks can share one fd table and the set of descriptors will be
dumped once and a image name will contain files_id instead of pid.
In this case CR_FD_FDINFO will go away from cr_fdset.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-11 14:47:09 +04:00
Andrey Vagin
dcf158e21d crtools: fix backward compatibility
crtools should not failed, if new images are absent.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-11 11:34:11 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04:00
Cyrill Gorcunov
a613842ddd tty: Fix slave peer index accounting
We need to test every even index (which represents a slave
peer) thus use modulo operation here.

Reported-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-11 20:58:11 +04:00
Cyrill Gorcunov
6b1d64ca9a tty: Use find_next_bit helper in tty_verify_active_pairs
Since we have find_next_bit in our sources now, lets
use for_each_bit helper to speedup a search procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-26 18:38:28 +04:00
Cyrill Gorcunov
c19cbc5c52 tty: Don't flush tty data on checkpoint stage
In case if we're dumping the peer which another
end belongs not to us but some other application
the attempts to flush data may lead to endless
SIGTTOU storm:

 | 1158  ioctl(53, TCFLSH, 0x2)            = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
 | 1158  --- SIGTTOU {si_signo=SIGTTOU, si_code=SI_KERNEL, si_value={int=5, ptr=0x5}} ---
 | 1158  --- stopped by SIGTTOU ---
 | 1158  ioctl(53, TCFLSH, 0x2)            = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
 | 1158  --- SIGTTOU {si_signo=SIGTTOU, si_code=SI_KERNEL, si_value={int=5, ptr=0x5}} ---
 | 1158  --- stopped by SIGTTOU ---

so simply don't flush data, the initial attempt to use
TCIOFLUSH was rather "hey, we don't have a way to
say the kernel to freeze tty link for a while, lets
try to workaround this limitation" but without proper
kernel help this won't work anyway as Andrey has discovered.

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 19:04:12 +04:00
Cyrill Gorcunov
4cff708663 tty: Make sure the controlling terminal is restored by session leader
The controling terminal should be sestored by a session leader,
thus we need to test if the SID we've found in process tree
is a leader.

Otherwise we might have pretty interesting situation: the user
passed -j on dump, ie telling us to inherit shell jobs and on
restore procedure the SID get inherited from the crtools but
session leader for this sid doesn't belong to our peocess tree
and thus we should not try to restore controlling terminal
but inherit it as well.

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 21:05:17 +04:00
Cyrill Gorcunov
76221d96c7 tty: Drop tty_lookup_task_sid helper
It's almost the same as find_first_sid, lets use
it instead.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 19:05:00 +04:00
Cyrill Gorcunov
598a4c21d6 tty: Open slave peers with O_NOCTTY
We have own mechanism to restore controlling
terminal thus we don't need the kernel to create
it in implicit way.

#2409

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 18:24:16 +04:00
Cyrill Gorcunov
6c53c74a06 tty: Rework tty_find_restoring_task
It's being found that we fail to restore tasks which
are not session leaders but have controlling terminals.

This patch reworks tty_find_restoring_task logic to fix
the problem. The problem itself basically was the following --
in case if there no sid present even on master peer or on both
master/slave peers, we were trying to find a restoring task,
and that's wrong since we have peers which do not belong our
session.

#2409

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 18:24:15 +04:00
Cyrill Gorcunov
e8d511943c tty: Don't try to restore controlling terminal via ptmx
The slave peer should be restoring the controlling terminal.
It works for most of programs but need some more investigation
in future.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:42 +04:00
Cyrill Gorcunov
f0606bc8d9 tty: Introduce deferred checking of tty sids
The dumping of tty peers is somewhat tricky. And it became more
complex once we allowed to migrate/inherit sessions.

It's being found (in screen c/r) that we've a problem in looking
up of session leaders while dumping tty.

Let me explain with more details. Here is an example of screen
session

  PID   GID   SID
20567 20567 20567           SCREEN
20568 20568 20568  pts/3     \_ /bin/bash

The screen opens master peer (ptmx) and then provides
bash the slave peer (pts/3) where bash sets up a session
leader on it.

Thus we get interesting scenario -- our pstree construction
is done in lazy fashion, we run parasite code to fetch sid/pgid
of a process tree item only when we're really dumping the task.

Thus when we start dumping ptmx peer (which belongs to SCREEN)
we've not yet constructed the process tree item for children
(ie /bin/bash) and the lookup function in tty code (which walks
over all process items in a tree) simply fails to find sid of
child, because we've not yet dumped it.

Thus, to resolve such situation we verify tty sids at late stage
of dumping.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:34 +04:00
Cyrill Gorcunov
84da534261 tty: Fixup error message in dump_pty_info()
The sid may be present not only on slave peer
so fix up the message. Also extend it showing
peer type.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:18 +04:00
Cyrill Gorcunov
f8fa75ae86 tty: Make tty_type to use @major argument
This makes this helper more wide usable.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:11 +04:00
Cyrill Gorcunov
4dc29af3ee tty: Use new ioctls granted by parasite
No need for tricks, we fetch everything we need
from the parasite.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:00 +04:00
Cyrill Gorcunov
8c1807ab38 tty: Add some comments in tty_find_restoring_task
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:36:35 +04:00
Cyrill Gorcunov
371caf2ff8 tty: Fix tty inheritance in case if zero sid fetched
In case if at checkpoint time we've fetched zero sid
associated with tty peer it doesn't obligatory means
that we've met a hangig up terminal, in particular
zero sid may be obtained if the slave peer do not
belong to the session the task run in but inherited
from the parent. Thus if --shell-job passed we should
handle such situation gracefully.

[ https://bugzilla.openvz.org/show_bug.cgi?id=2405 ]

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:36:18 +04:00
Cyrill Gorcunov
5cb163411e tty: Lookup for controlling tty iif sid provided
This is rather a code tossing for the next patch.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:35:47 +04:00
Cyrill Gorcunov
1945a83b0c tty: More detailed printing on unpaired slaves
In case of errors it provides us more information about what is going on.

For example, in my test case I now can see where the error came from

 | (00.027248) tty: Unpaired slave 0
 | (00.027261) tty: Unpaired slave 2
 | (00.027273) Error (tty.c:174): tty: Only one slave external peer is allowed (index 2)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-22 15:48:42 +04:00
Cyrill Gorcunov
8f81f589ae tty, restore: Migrate tty slave peer connection if --shell-job passed
In case if we've dumped a slave peer only (say a user dumped `top'
application) we should migrate it on current active terminal, which
barely an own standart stream prepared for us by the file engine.

Note only one external slave peer is allowed simply because
otherwise we can't distinguish which indices should be used
for each of them.

The patch basically does the following things

 - Check if the SID present on peer exist in current
   process tree, we need to be sure that we can restore
   peer parameters and controlling terminal if present

 - Rename pty_open_fake_ptmx to pty_open_unpaired_slave
   because we might be inheriting SELF_STDIN_OFF instead
   of opening fake master peer

 - Do inherit SELF_STDIN_OFF and restore tty group if
   we are restoring external tty

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-18 15:52:01 +04:00
Cyrill Gorcunov
bee5ddfb7a tty: Update tty verification procedure
We need to make sure that the only one external tty
is present, since otherwise we have no idea on which
pts index to connect them on restore.

This patch extends tty_verify_active_pairs procedure to
count how many external tty is present in the dump image.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-18 15:52:00 +04:00
Cyrill Gorcunov
c2f44646b6 tty: Mark collected tty in @tty_active_pairs bitmap
Upon reception of tty we need to mark it in @tty_active_pairs
bitmam thus we will be able to verify if

 - all active ttys obtained are paired
 - if not paired then only one external tty is allowed

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-18 15:51:59 +04:00
Cyrill Gorcunov
9c579cfd02 sfd_type: Add SELF_STDIN_OFF service fd and call helpers where needed
We will need it for slave ttys migration. They serve for one purpose --
to clone self stdio descriptor and use it with tty layer, which will
be addressed in further patches.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-18 15:51:56 +04:00
Pavel Emelyanov
33c0add242 tty: Sanitize tty parasite-side dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-15 23:55:34 +04:00
Cyrill Gorcunov
9fb384f926 tty: Make tty_get_sid_pgrp() to use parasite code
We need to use namespace local sid/pgid parameters
assigned on tty link, thus use parasite helper.

Otherwise we might fail on restoring controlling
terminal inside namespace (though everything else
will work even without this patch).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-15 23:42:54 +04:00
Cyrill Gorcunov
848215b6f1 tty: Drop sid/pgid test from verify_info
Since we've started fetching sid/pgid from the
dumpee context we're allowed to obtain sid/pgid
on a slave peer. This is perfectly valid. So
drop this test.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-15 23:42:52 +04:00
Cyrill Gorcunov
1686669410 tty: Make tty_setup_slavery to return error
In case if here no task found which would restore
controlling terminal -- exit with error instead of
continue with just error message.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-15 20:02:29 +04:00
Cyrill Gorcunov
6a5ac97186 tty: Fix copying of termios character map
The system termios structure and our PB
equivalent defined quite different, while
first defined as plain array we use dynamically
allocated memory. Thus the use of min() macro
is incorrect here and always produce the size of
pointer.

Fix it using the size of array from the system
provided structure. The BUILD_BUG_ON will prevent
from accidental changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-02 20:26:11 +04:00