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

36 Commits

Author SHA1 Message Date
Pavel Emelyanov
d4df900236 unseize: Don't print error when unseizing stopped task into stopped state
Just a small mistake in prev patch.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 23:22:04 +04:00
Andrew Vagin
a2eaa5cf44 ptrace: the task state is restored automatically
It's a feature of PTRACE_SEIZE.  So we need to do something, only
if we want to change the state.

[xemul: If task _was_ in stopped state before dump and we want them
 to stay alive after dump, the existing code queues one more STOP
 to it. This affects subsequent dump, as we seize a stopped task
 with STOP in queue.

 One more item in TODO list -- support stopped tasks with STOP in
 queue :)
]

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 20:36:12 +04:00
Pavel Emelyanov
805e25effe ptrace: Add comment about early interrupt
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:42:24 +04:00
Andrey Vagin
dc914912ec dump: try to stop a task as soon as possible
We read /proc/pid/status to determine a task state, but if a task is
running in this moment, its state may be changed.

This patch stops tasks before reading their /proc/pid/status

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:16:12 +04:00
Kir Kolyshkin
abd061481b pr_perror(): don't end message with a period
When pr_perror is used, an error message is appended with a comma
and an strerror(errno), so we should not put a period at the end,
otherwise we'll end up with something like this:

	Error: Can't bind.: Permission denied

Found by git grep -w pr_perror | grep '\."'

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:58:05 +04:00
Andrey Vagin
a434e7f075 crtools: move pid_rst_prio to pid.h
crtools.h is too heavy to be included in many sources

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:18:12 +04:00
Andrey Vagin
79d47a939d crtoools: add support of stopped tasks (v2)
Currently we catch processes on the exit point from sigreturn.
If a task must be restored in the stopped state, we can send SIGSTOP
before detaching from it.

v2: add more descriptive comment about skipping SIGSTOP in ptrace.c
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:21:34 +04:00
Kir Kolyshkin
c19e62f87c Change crtools to criu in criu messages
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-10 11:02:20 +04:00
Andrey Vagin
d4e1df3a03 ptrace: don't call PTRACE_INTERRUPT many times
According to the commit message in the kernel git, a new trap flag
JOBCTL_TRAP_INTERRUPT is added, which is set on PTRACE_INTERRUPT and
cleared when any trap happens.

Currently we have a race window beetwen PTRACE_CONT and
PTRACE_INTERRUPT. If a process stops before PTRACE_INTERRUPT,
the flag JOBCTL_TRAP_INTERRUPT will be set once again.

https://bugzilla.openvz.org/show_bug.cgi?id=2569

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-23 20:55:20 +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
18242f8319 seize: Warn if crtools tried to seize self
That's not allowed by kernel, but having explicit message is nice.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 01:10:56 +04:00
Pavel Emelyanov
b6fa2b31a7 ptrace: Be more verbose on seize failure
The ptrace seize may fail for various reasons. E.g. -- no enough perms
to get the ptrace access to the tasks, or various selinux restrictions.

Print what exactly has happened when ptrace failed.

Reported-by: Kevin Wilson <wkevils@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-26 22:03:15 +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
Pavel Emelyanov
679c5326c3 ptrace: Remove dead code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 23:33:06 +04:00
Pavel Emelyanov
59a2f13e7e Helper for si_code event extraction.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-25 21:35:40 +04:00
Pavel Emelyanov
b749f4b1c3 ptrace: Fix to use new (final) SEIZE functionality
Since 3.4-rc the seize-devel flag is removed, the stop event
is renamed (great) and the way si_code should be parsed has
been fixed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-25 21:35:38 +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
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
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
Cyrill Gorcunov
7aa8e4b6e2 log: log-engine slight redesign
The messages are filtered by their type

    LOG_MSG     - plain messages, they escape any (!) log level
                  filtration and go to stdout
    LOG_ERROR   - error messages
    LOG_WARN    - warning messages
    LOG_INFO    - informative messages
    LOG_DEBUG   - debug messages

By default the LOG_WARN log level is used, thus LOG_INFO
and LOG_DEBUG messages will not appear in output stream.

pr_panic helper was replaced with pr_err, pr_warning
shorthanded to pr_warn and old printk if rather pr_msg
now.

Because we share messages between "show" and "dump" actions,
before the "show" action proceed we need to tune up
log level and set it to LOG_INFO.

Also note that printing of VMA and siginfo now
became LOG_INFO messages, it was not that correct
to print them regardless the log level.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-02 01:05:43 +04:00
Pavel Emelyanov
cb0eb0b31e dump: Let task handle signals on seize
When seizing a task and waiting for it to stop, we can receive an event
from kernel, that the task didn't stop, but caught a signal. Don't treat
this as an error, let the victim handle it and proceed.

The transition/fork test should work OK now.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 20:36:36 +04:00
Pavel Emelyanov
9e0b308af0 dump/restore: Rework final-state switch
Remove CR_TASK_XXX states, use the TASK_XXX ones (for image). This is
required to unseize tasks properly in the next patches.

Plus, make sure that pstree_list and the seized set coincide (i.e.
handle error in collect_task).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:20 +04:00
Pavel Emelyanov
199e8d8248 dump: Check for pids reuse at suspend
While we try to seize task it can die and give its pid to
somebody else. This can break pstree consistency. Check for
parent being valid after task is seized.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:20 +04:00
Pavel Emelyanov
f8a18edd44 dump: Remove SHOULD_BE_DEAD task state
Move proc checks for Z-state into seize_task().

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:20 +04:00
Cyrill Gorcunov
dcb1cbfb82 Rework parasite code
- make control block to keep all information
   needed to run injected syscall and parasite
   blobs

 - add ptrace_swap_area helper

 - handle both parasite engine calls and injected
   syscalls by single __parasite_execute function

 - drop jerr() usage

 - bring back handling of inflight signals from
   original program inside parasite code

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-16 22:05:28 +04:00
Pavel Emelyanov
06cc19511a ptrace: Send signals with final state explicitly
According to Oleg the PTRACE_KILL doesn't and was-not-supposed-to work.
Thus, kill tasks to final state explicitly and just detach from them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-03 14:54:26 +04:00
Pavel Emelyanov
766a42e316 ptrace: Kill task with -9 explicitly when detaching
Strange fact, but a task seems to live for some time after PTRACE_KILL :(
Don't know yet why this happens, I'm poking Oleg on that, but this one makes
it die right at once.

The streaming file read test passes after this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-01 22:17:56 +04:00
Cyrill Gorcunov
e61605169f ctrools: Rewrite task/threads stopping engine is back
This commit brings the former "Rewrite task/threads stopping engine"
commit back. Handling it separately is too complex so better try
to handle it in-place.

Note some tests might fault, it's expected.
---

Stopping tasks with STOP and proceeding with SEIZE is actually excessive --
the SEIZE if enough. Moreover, just killing a task with STOP is also racy,
since task should be given some time to come to sleep before its proc
can be parsed.

Rewrite all this code to SEIZE task and all its threads from the very beginning.

With this we can distinguish stopped task state and migrate it properly (not
supported now, need to implement).

This thing however has one BIG problem -- after we SEIZE-d a task we should
seize
it's threads, but we should do it in a loop -- reading /proc/pid/task and
seizing
them again and again, until the contents of this dir stops changing (not done
now).

Besides, after we seized a task and all its threads we cannot scan it's children
list once -- task can get reparented to init and any task's child can call clone
with CLONE_PARENT flag thus repopulating the children list of the already seized
task (not done also)

This patch is ugly, yes, but splitting it doesn't help to review it much, sorry
:(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-01 19:49:28 +04:00
Cyrill Gorcunov
63b88720a3 Revert "ctrools: Rewrite task/threads stopping engine"
This reverts commit 6da51eee3f6cd7aca9dd88275844e73fb78b767b.

It breaks transition/file_read test case
2012-02-01 19:27:28 +04:00
Pavel Emelyanov
6da51eee3f ctrools: Rewrite task/threads stopping engine
Stopping tasks with STOP and proceeding with SEIZE is actually excessive --
the SEIZE if enough. Moreover, just killing a task with STOP is also racy,
since task should be given some time to come to sleep before its proc
can be parsed.

Rewrite all this code to SEIZE task and all its threads from the very beginning.

With this we can distinguish stopped task state and migrate it properly (not
supported now, need to implement).

This thing however has one BIG problem -- after we SEIZE-d a task we should seize
it's threads, but we should do it in a loop -- reading /proc/pid/task and seizing
them again and again, until the contents of this dir stops changing (not done now).

Besides, after we seized a task and all its threads we cannot scan it's children
list once -- task can get reparented to init and any task's child can call clone
with CLONE_PARENT flag thus repopulating the children list of the already seized
task (not done also)

This patch is ugly, yes, but splitting it doesn't help to review it much, sorry :(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-01 17:29:13 +04:00
Kir Kolyshkin
0b237ae9f2 pr_perror(): print error at the end of line
This is a standard convention to print error message (i.e. strerror(errno))
at the end of line, like this:

        Cannot remove file: Permission denied

So pr_perror is fixed to follow this convention (using GNU extension
%m helps a lot here). Unfortunately, due to this we have to make
pr_perror() print a new line character, too, so we had to strip it
from the all pr_perror() invocations.

That (appending a newline) also makes pr_perror() a black sheep
in the herd of pr_* helpers, but what can we do? Worst case scenario
is an extra newline after an error message, not too harmful.

An alternative approach (stripping the newline from the passed format
string and re-adding it) was discussed thoroughly, and it was decided
that such a hack looks a bit too dirty.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:49:15 +04:00
Pavel Emelyanov
7e8eb76e9d ptrace: Print proper errors when seize failed
I'd appreciate if we get rid of these misleading macros at all eventually...

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-19 22:41:52 +04:00
Pavel Emelyanov
0ca9ccc3e4 crtools: Sanitize the tasklist states switch
Introduce a helper for walking the list and sending signals.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 13:59:15 +04:00
Cyrill Gorcunov
681ef94fc0 ptrace: Drop unneeded #includes
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 23:25:08 +04:00
Cyrill Gorcunov
2e3c4e3692 Move everything related to ptrace into ptrace.[ch]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 21:57:59 +04:00