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

94 Commits

Author SHA1 Message Date
Pavel Emelyanov
bced873181 tty: Per-type fd_get_index callback
This one gets index from fd/fd_parms pair on dump. For
console and vt the index is constant and just sits on
the tty_type (will also be used on restore, see next
patch).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:07 +03:00
Pavel Emelyanov
a9ae0ab6d9 tty: Put tty name on tty_type
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:06 +03:00
Pavel Emelyanov
057f00ce92 tty: Make tty type be object rather than integer
The plan is to replace tons of if (type == TTY_TYPE_FOO) checks
with type->something dereferences.

To do this, start with replacing int type with struct tty_type *
in relevant places and fixing compilation.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:04 +03:00
Pavel Emelyanov
a7601d6a50 tty: Move tty_type() and is_pty() to tty.c
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:46:16 +03:00
Pavel Emelyanov
3a25abdad2 tty: Use tty_name in prints
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:45:08 +03:00
Cyrill Gorcunov
9be7769017 tty: Fix typo in tty_setup_slavery for VT
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-20 00:11:47 +03:00
Pavel Emelyanov
7d482de1ca tty: Restore locked termios with usernsd call
Locked termios require global CAP_SYS_ADMIN. But let's
restore everything for tty in one call since regular
termios depend on locked and it's not nice to do sync
usernsd call for locked only.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2015-02-13 16:11:38 +04:00
Pavel Emelyanov
feda34319a tty: Assign empty file_desc_ops to fake file descs
The newer cleanups in fd inherit code need every file-desc
to have non-NULL ops. This hunk was lost in tty code in the
very beginning.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-13 22:19:58 +03:00
Ruslan Kuprieiev
2d91ff5f2e tty:add comment explaining indices, v2
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-22 13:48:45 +03:00
Ruslan Kuprieiev
1ace257022 tty: add vt support, v2
/dev/ttyN are the virtual terminals which are provided
by the system with major 4 and minor 1..63.
You can run some program on ttyN by pressing alt+ctrl+FN
and running it manualy or by using open(openvt nowadays).

This patch also allows us to run all our tests from a vt.

v2, style fix + using linux/vt.h for constants

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-22 13:48:31 +03:00
Cyrill Gorcunov
4cb9eaf39f tty: Fix compilation warrning
| tty.c: In function ‘tty_restore_ctl_terminal’:
 | include/criu-log.h:42:16: error: ‘index’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Same time assign CONSOLE_INDEX for debug info.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-30 16:24:15 +04:00
Tycho Andersen
a6e746ba17 tty: don't crash if restoring a non-pty
The pty field here is only present with certain tty types, so we shouldn't
unconditionally dereference it, or criu will hang.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-30 15:14:49 +04:00
Cyrill Gorcunov
ec50bd8c91 tty: Add support of /dev/console
/dev/console is a system console which provided
by the system with major 5 and minor 1. It's usually
configured on system startup with console= option
and underlied driver is resposible to deliver messages
to the console user.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:35:39 +04:00
Cyrill Gorcunov
a9c724142d tty: Fix path inversion for /dev/pts/ptmx
Need to compare the /pts/ part in the
former path, otherwise it will produce
bogus /dev/pts/pts/index form.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 22:14:41 +04:00
Cyrill Gorcunov
caa64d974d tty: Use regular files engine to save paths to the peers, v5
Currently we're using predefined format for master/slave pty peers:
masters are always /dev/ptmx, while slaves are /dev/pts/$index,
where $index is the peer number.

While fitting most of distros this is not always correct and slave peers
might be mounted to an arbitrary place, so that we need to somehow
carry paths with ourself in image.

Instead of bloating current tty image lets use regular file engine instead
and on checkpoint stage save a path to the link in regfiles set, then on
restore simply fetch it from the image.

Such approach will help in future when we need to support multiple
instances of devpts filesystem.

To support backward compatibility with images where no regfile
records are present we generate new one on the fly in
pty_alloc_reg() helper.

Because of the need to restore dead slave peers and restore of
the controlling terminal we need to generate that named "fake
inverted" pty_alloc_fake_reg() helper: in particular if
we need to open dead slave peer we generate fake master peer,
open it and the close out. Almost the same situation in
restoring contolling terminal -- we get master peer, generate
appropriate fake slave object, open it, manipulate, then
close it out and free.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:54:23 +04:00
Cyrill Gorcunov
09aa15c7a3 tty: Parse slave peer index from fd_parms
We will use this path in reg-files engine anyway
so simply switch to this ability now.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:30 +04:00
Cyrill Gorcunov
d6e231ae09 tty: parasite -- Don't call for TIOCGPKT/TIOCGPTLCK on non-ptys
We will have to support more tty types in future so
make calls depending on type of ttys.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:27 +04:00
Cyrill Gorcunov
bcc1f4eb72 tty: Introduce tty types
Instead of calling case() with majors all over the places lets
introduce own enum for tty types and use it instead.

Because we're using not @major numbers now but taking @minors
into account as well, this brings more strict check of which
kind of terminals we can dump now thus it's potentially should
fix the cases when we're trying to c/r terminals which we don't
understand yet (in particular /dev/console [5:1]).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:26 +04:00
Cyrill Gorcunov
bc5fcaa777 tty: collect_one_tty -- Use tty_is_master helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:53:34 +04:00
Cyrill Gorcunov
87418490e5 tty: Rename helpers to reflect the type of peers
- parse_index -> parse_pty_index since it's PTY specific
 - pty_is_master -> tty_is_master because it will test
   not only PTY peers but other types as well
 - pty_is_hung -> tty_is_hung for same reason

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:52:23 +04:00
Cyrill Gorcunov
d311fd3e46 tty: Add some comments about console and bsd terminals
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:50:33 +04:00
Cyrill Gorcunov
9b5e050906 tty: Instead of BUG_ON exit out with error early
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:50:04 +04:00
Cyrill Gorcunov
b708a7d549 tty: Align members in assignments
For readability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:49:47 +04:00
Pavel Emelyanov
c443b03e10 rst: Rework the rst_info referencing
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-01 13:34:38 +04:00
Pavel Emelyanov
5f2a7ac27b img: Rename fdset -> imgset
Since we're going to switch from int-fd-s to class-image
soon the fdset name will not fit into the new terminology.

This patch is

 sed -e 's/fdset/imgset/g' -i *
 sed -e 's/imgset_fd/img_from_set/g' -i *
 git mv include/fdset.h include/imgset.h

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
2014-09-30 21:48:10 +04:00
Andrey Vagin
bff466c291 tty: open tty-s with O_NOCTTY
When we open tty, we don't want to set it as controlling terminal.

[xemul: We do it in all the other places, this one is forgotten.
 The "controlling tty" feature is setup explicitly later with
 the ioctl (TIOCSCTTY) call. ]

This bug was caught by pty04. Where we get unexpected SIGCONT,
which is sent after closing a controlling terminal.

./pty04 --pidfile=pty04.pid --outfile=pty04.out
Dump 9578
Restore
Test: zdtm/live/static/pty04, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/pty04, Namespace:
Dump log   : /home/jenkins/workspace/Rpi-CRIU/test/dump/static/pty04/9578/1/dump.log
--------------------------------- grep Error ---------------------------------
------------------------------------- END -------------------------------------
Restore log: /home/jenkins/workspace/Rpi-CRIU/test/dump/static/pty04/9578/1/restore.log
--------------------------------- grep Error ---------------------------------
(00.083420) Error (cr-restore.c:1092): 9578 killed by signal 0
(00.083708) Error (cr-restore.c:1713): Restoring FAILED.
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-15 13:28:16 +04:00
Pavel Emelyanov
3de41b8070 files: Rework select_ps_list fdsec ops callback
For unlinked opened and mmaped files we'd need to
care about remaps, for this the callback with both
file_desc and fdinfo_list_entry will be required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-05 16:17:59 +04:00
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