2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00
Commit Graph

2398 Commits

Author SHA1 Message Date
Cyrill Gorcunov
4685b56336 zdtm: Add cpuid.h
The test for fpu transition will require to do
a runtime check for the cpu features it's running
on. For this sake we need to use cpuid. Thus make
it more widely available by providing in the general
header.

The code is adopted from the linux kernel code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:44 +04:00
Cyrill Gorcunov
3eb28f9fbc restore: Restore FPU state
Since at moment we stick with sigreturn restore
we need to form a proper FPU frame and set a pointer
to it inside sigreturn frame.

For this sake we read the FPU image and here are two
cases are possible

 - no fpu data at all -- nothing to restore, simpliest
   case

 - xsave frame is present but the host cpu supports only
   fxsave instruction: we refuse to continue, since it means
   there are no ymm registers on the machine where we're trying
   to restore

 - fxsave frame is present but the host cpu has xsave feature:
   at moment we refuse to continue, requiring complete match
   between "checkpoint and restore hosts", but in real we could
   extend logic and form complete xsave frame from fxsave and
   continue processing

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:43 +04:00
Cyrill Gorcunov
9fee76bd31 restore: Reserve space in restorer for FPU frame
For code simplicity we reserve the maximum size which
might be needed to form an FPU frame (ie for both
xsave and fxsave operations).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:42 +04:00
Cyrill Gorcunov
10f22fe9ee restore: Change rt_sigcontext::fpstate to void *
It will be carrying xsave or fxsave frame.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:41 +04:00
Cyrill Gorcunov
c1f7ab2150 checkpoint: Add dumping of FPU state
The dumping of FPU state is done with help of ptrace
facility. There are two cases which we need to handle
depending on which features are available on host machine

1) The dump via ptrace(PTRACE_GETFPREGS ...)

   In this case the kernel will use fxsave approach
   inside the kenrel and provides us back the data
   encoded in i387_fxsave_struct format.

2) The dump via ptrace(PTRACE_GETREGSET ...)

   In this case the kernel will use xsave approach
   inside the kernel and provides us back the data
   encoded in xsave_struct format.

In any case we decode data and save it in protobuf format.
This is why core.proto file has been extended to keep new
entries.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:39 +04:00
Cyrill Gorcunov
8b93676d90 dump: Move assign_reg/assign_array closer to place where they are used
And don't forget to undef them once they are not needed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:38 +04:00
Cyrill Gorcunov
1256c390b6 dump: Drop FPU padding allocation
Actually it was never used, just drop it.
Because of backward compatibility problem we
can't just zap it in protofile.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:37 +04:00
Cyrill Gorcunov
41ebf5c377 cpu: Add testing if host cpu is suitable to FPU c/r
The cpu we're running on must at least support fxsave feature.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:36 +04:00
Cyrill Gorcunov
cf2e6c54c9 cpu: Add code to fetch/test cpuinfo data
This patch add ability to test /proc/cpuinfo data
we're interested in at the moment.

The code provides the following functionality

 - cpu_init, to parse cpuinfo and check if the
   host cpu we're running on is suitable enough
   for FPU checkpoint/restore. If FPU present then
   there must be at least fxsave capability present

 - cpu_set_feature/cpu_has_feature helpers which
   provides to test certain bits and set them where
   needed (we need to set bits when parse cpuinfo)

Note, we reserve space for all cpuinfo bits known
by the kernel at moment, while use only three FPU
related bits for a while. This is done because we might
need to use or find out other features in future.

After all it's just 40 bytes of memory needed to keep
all possible bits.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:34 +04:00
Cyrill Gorcunov
666f4ebbe9 fpu: Add fpu.h header
We will need these structures for restore FPU
state via sigframe, as as we decode data provided
by ptrace.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:33 +04:00
Andrey Vagin
2701316b46 dump: remove debug messages
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-20 16:08:12 +04:00
Andrey Vagin
7d8e13e225 parasite: add ability to execute more than one crtools dump simultaneously
A name of a unix socket should be uniq

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-20 16:07:44 +04:00
Pavel Emelyanov
4ced9531e6 files: Open-code MAKE_GEN_ID macro into its single caller
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-18 21:29:48 +03:00
Pavel Emelyanov
1e538cf02b dump: Drop unused image file perm change before sending it to parasite
Since we send _fd_ it's pointless to call chmod on image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-18 21:01:53 +03:00
Pavel Emelyanov
5ff013391b parasite: Fix exchang area size handling
Wrong size was used in mapping and unmapping. But since
they are more-less close to each other, nobody noticed it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-18 20:48:56 +03:00
Pavel Emelyanov
0f58bae4ce doc: Add syscalls execution description
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-18 00:39:20 +03:00
Pavel Emelyanov
15901c2d76 exec: Implement basic remote syscall execution
Syntax is

crtools exec -t <pid> <syscall_name> [<arguments>]

Two types of arguments are supported -- plain, treated
as number, passed as is to the syscall. Buffer, started
with '&' -- the rest of the string is pushed to the tgt
task's memory and pointer to one is passed as syscall
argument.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-18 00:26:37 +03:00
Pavel Emelyanov
4bb4ece76e exec: Initial skeleton
Reserve the cmdline option for this and link empty file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-17 22:56:06 +03:00
Pavel Emelyanov
45fdee04fb parasite: Split infecting routine into parts
The fist part prepares ctl to controll the seized task.
The 2nd one mmaps shareb buffer for data exchange.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-17 22:53:23 +03:00
Pavel Emelyanov
3b404e3776 parasite: Introduce generic syscall-calling function
This one calls a syscon on seized task. Existing mmap/munmap
just use one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-17 22:52:06 +03:00
Pavel Emelyanov
9428f3a9a2 dump: Make collect_mappings non static
Will be used by other code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-17 22:50:06 +03:00
Pavel Emelyanov
4199022be5 parasite: Remove typedef-ed type from parasite header
I'll include it into a place, that knows nothing about
pb types. Use generic pointer instead.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-17 22:49:30 +03:00
Pavel Emelyanov
bb2d78b0b7 x86: Teach syscall table generating script accept argument
We'll have to generate syscall table in another form,
prepare for it
.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-17 22:47:17 +03:00
Pavel Emelyanov
d7259d863f help: Print shorter help when lanuched w/o arguments
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-17 22:39:10 +03:00
Pavel Emelyanov
d721e9d48c criu: Version 0.3 release
This is mostly bugfix and improvements release.
Nonetheless, some new features exists, the most interesting are:

  * proper COW mappings handling
  * full packet sockets support, thus supporting the tcpdump tool
  * the --shell-job option, which makes it possible to dump apps
    launched from one shell and restore them in another

Some features are available with the custome kernel, but the good
news is that now _all_ of the patches we need are in one of the
-next trees or in the -mm one, and thus have good chances to get
merged in 3.8 (or soon after it).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v0.3
2012-12-11 21:22:55 +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
Pavel Emelyanov
11f8bb4705 show: Show *-s for zero sequences in hexdump output
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 19:19:24 +03:00
Pavel Emelyanov
12602aee59 show: Make hexdump output look like hexdump tool one
No spaces between chars and no 0x-s.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 19:00:05 +03:00
Pavel Emelyanov
56e1decf48 show: Factor out skipping of data dump into show_image_data
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 18:57:54 +03:00
Stanislav Kinsbursky
c33a62dfcc ipc: fix silly misprint in IPC shm show handler
IPC shared memory data is aligned by 32 bits.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 17:19:34 +04:00
Pavel Emelyanov
1d1860224e rst: Remove excessive arg from open_vmas()
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 16:08:07 +03:00
Pavel Emelyanov
87fe1834cd rst: Sanitize restore function call flow
The dedicated prepare_and_sigreturn makes code harder to read.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 16:04:46 +03:00
Pavel Emelyanov
25e31a933b pstree: Remove unneeded arg from prepare_pstree_for_shell_job
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 15:54:12 +03:00
Pavel Emelyanov
be79f38d6c pstree: Sanitize pstree preparation code
We have 3 calls for that, two called directly from cr-restore,
one -- from one the former. Clean this mess and write short
comments on each stage.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 15:50:47 +03:00
Pavel Emelyanov
2a925722ca show: Show itimers with std pb showing helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 16:34:03 +03:00
Pavel Emelyanov
0026b53678 mnt: Don't allocate PATH_MAX on stack for pivot path
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 16:20:19 +03:00
Pavel Emelyanov
dbbd8d400a rst: Don't allocate PATH_MAX on stack for proc mountpoint
Use direct name assignment, it's enough.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 15:50:41 +03:00
Pavel Emelyanov
da8dbe43bc rst: Move premmaped* variables on rst_info
This thing on pstre_item was created to carry task-specific
information across the "restore" code-flow.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 13:19:01 +03:00
Pavel Emelyanov
39d60cdfef rst: Sanitize sigchld handler
The error handling was not obvious. Clean it up.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 13:08:56 +03:00
Pavel Emelyanov
815049bcdb rst: Fix message about inability to restore pid 1 outside pidns
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 10:58:32 +03:00
Cyrill Gorcunov
d9df71dc87 zdtm: Extend inotify00 test to have ghost file used
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 11:11:22 +04:00
Cyrill Gorcunov
b146fe4af6 inotify: Use ghost files if the watchee is a deleted file, v2
The watch target might be a deleted file. In this case we can't
re-create it on restore procedure.

A typical scenario
------------------

 fd = inotify_init1()
 wd = open(path)
 inotify_add_watch(path)
 unlink(path)
 ... checkpoint ...

here we have a @path which is unlinked but still present in inotify
watch list because inode is not yet freed. And if the program is killed
after checkpoint the last reference to a path get eliminated and inode
get freed from the kernel memory.

Thus any furher attempts to open the path via file handle (note that file
handle can't be used to create new file, the kernel doesn't permit that)
will simply fail.

So if plain opening via file handle failed we assume that at least
the file might be in our ghost files list (we're optimists, right?)
and if we successed we simply use a path generated by ghost file
engine for us.

v2 [by xemul@]:
 - gather reference to ghost file remap early

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 11:11:19 +04:00
Cyrill Gorcunov
7eb33a76a8 ghost-files: Save device and inode in image
Because we need to lookup for ghost files from
inotify system where we only have device/inode
as a key, we save dev/ino in ghost image entry.

Note we use in-kernel format for device to be
consistent with inotify and mount related
code base.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 11:11:10 +04:00
Cyrill Gorcunov
7bd34c699e files-reg: Add a few helpers to access ghost files remaps from inotify
The remap_put will be needed to defer unlinking of ghost files
if they are referred from inotify system.

The lookup_remap is needed to figure out if the watch
target the inotify has present in ghost files list.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 11:10:14 +04:00
Cyrill Gorcunov
746ac3fee5 files-reg: Move struct file_remap to the header
We will need to use it in inotify code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 11:10:10 +04:00
Pavel Emelyanov
bae3324447 ghost: Cleanup ghost file dumping
No need in function-wide fd variable for copying file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-05 22:59:35 +03: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
4cd9998544 rst: Brush up fake vs real tasks post-pgid restore codeflow
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 18:49:36 +03:00
Pavel Emelyanov
9e7ae345db rst: Remove unused arg from restore_one_helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 18:43:28 +03:00
Cyrill Gorcunov
fdc56e53f6 proc_parse: Update inotify format
Since fdinfo patches were merged to -mm
tree the output format has been slightly
changed. So update our tool accordingly.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 19:28:45 +04:00