Commit graph

5000 commits

Author SHA1 Message Date
Saied Kazemi
490ca71866 Fix AUFS pathname handling when branch is not exposed
The code that fixes up AUFS pathnames associated with vma entries (see
commit d8b41b6525) should handle cases where an entry does not expose
the branch pathname (e.g., pointing to a device like /dev/zero).

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-19 13:05:12 +03:00
Pavel Emelyanov
7b4a264e28 crit: Small inf/outf evaluation cleanup
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-15 19:51:18 +03:00
Ruslan Kuprieiev
a9ccdccc34 pycriu: images: pb2dict: perform pb<->json conversion properly
Currently we are handling conversion in the simplest way, by
just parsing protobuf text format representation of pb message,
splitting string in half and storing values wrapped in ""-s
in python dict. Which leads to a bunch of errors, like,
for example, when converting bytes fields. It also doesn't
handle types properly.

This patch introduces a proper way to handle pb<->json conversion
by iterating through pb fields and properly storing them in dict
or properly extracting values from dict.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-15 20:46:23 +04:00
Pavel Emelyanov
8878793d39 crit: Fix sk-queues extra handler variable name
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-15 02:07:00 +04:00
Ruslan Kuprieiev
0956230709 pycriu: images: mention raw data images when throwing an 'Unknown magic' exception
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:47:48 +04:00
Ruslan Kuprieiev
9761dc3a70 test: crit: use decode/encode instead of convert
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:47:47 +04:00
Ruslan Kuprieiev
1a30e8800e crit: fix typo
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:47:47 +04:00
Ruslan Kuprieiev
7a8ddc0f4a crit: split convert command into decode and encode
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:47:46 +04:00
Ruslan Kuprieiev
598a83cfd3 pycriu:images: treat pagemap.img as a special one
pagemap.img is the special one, as it starts with an entry
of pagemap_head type and is followed by entries of
pagemap_entry type. Currently we treat pagemap as if
pagemap_head is a payload and pagemap_entry's are
an extra, which is wrong.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:47:45 +04:00
Ruslan Kuprieiev
4997896bf4 pycriu: images: merge payload field into entry and add extra field to entry if needed
Before:
{
    "magic" : "FOO",
    "entries" : [
        {
            "payload" : {
                "foo" : "bar",
                "bar" : "foo"
            },
            "extra" : "abc"
        },
        {
            "payload" : {
            "foo" : "bar",
            "bar" : "foo"
            },
            "extra" : "abc"
        }
    ]
}

After:
{
    "magic" : "FOO",
    "entries" : [
        {
            "foo" : "bar",
            "bar" : "foo"
            "extra" : "abc"
        },
        {
            "foo" : "bar",
            "bar" : "foo"
            "extra" : "abc"
        }
    ]
}

We don't have any fields named "extra" in our pb msgs and it is
not likely that we will ever have one, so there is no reason to
worry about that.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:47:44 +04:00
Ruslan Kuprieiev
912f1a5afb crit: print new line if orig_type == bin and using stdout
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:47:43 +04:00
Ruslan Kuprieiev
12db8f23f5 test: add crit test
Test steps:
1) generate img files by dumping loop.sh
2) convert img files to json files
3) convert json files to img files
4) cmp original and produces img files

It also uses i/o redirection and --format nice options to
check if they work properly.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:44:50 +04:00
Ruslan Kuprieiev
ec9ab827b1 crit: add install-crit target to Makefile
install-crit uses scripts/crit-setup.py install --prefix=$(DESTDIR)
to act the way the install target expects it too.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:44:49 +04:00
Ruslan Kuprieiev
def0f49177 crit: add scripts/crit-setup.py
This is a small python scipt that uses distutils to install crit script
and pycriu package.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:44:48 +04:00
Ruslan Kuprieiev
9d169c550b crit: add crit target to Makefile and *.pyc to .gitignore
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:44:47 +04:00
Ruslan Kuprieiev
d36994c4c3 crit: add crit
crit is a python script that helps user to manipulate criu
images. For now, it can only convert criu images to\from
human-readable format using pycriu.images module.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:44:47 +04:00
Ruslan Kuprieiev
dfe8f838cf pycriu: add python package
pycriu is a python package, that, for now, consists
of rpc module and images package. rpc module contains
data structures for interacting with CRIU RPC.
images package contains methods for loading\dumping
criu images.

See a big comment below in pycriu/images/images.py file.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:44:46 +04:00
Ruslan Kuprieiev
e7640ad635 scripts: add magic-gen.py
This script is needed to generate python module from
include/magic.h file, that contains dicts with magic
numbers that we put into our criu *.img files.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-14 20:44:45 +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
Mark O'Neill
af91bfa241 Signed-off-by: "Mark O'Neill" <mao@tumblingdice.co.uk>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 17:04:34 +03:00
Saied Kazemi
296129295a Allow the veth-pair option to specify a bridge
When restoring a pair of veth devices that had one end inside a namespace
or container and the other end outside, CRIU creates a new veth pair,
puts one end in the namespace/container, and names the other end from
what's specified in the --veth-pair IN=OUT command line option.

This patch allows for appending a bridge name to the OUT string in the
form of OUT@<BRIDGE-NAME> in order for CRIU to move the outside veth to
the named bridge.  For example, --veth-pair eth0=veth1@br0 tells CRIU
to name the peer of eth0 veth1 and move it to bridge br0.

This is a simple and handy extension of the --veth-pair option that
obviates the need for an action script although one can still do the same
(and possibly more) if they prefer to use action scripts.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:54:18 +03:00
Christopher Covington
70f28122e5 aarch64: Fix restore for multithreaded processes
The stack handling in the RUN_CLONE_RESTORE_FN macro for
AArch64 was incorrect, resulting in a segfault of the restored
process. With this change the pthread00 test case (and probably
others) runs to completion and passes.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:51:57 +03:00
Ruslan Kuprieiev
0c366dd887 zdtm: git: add some test binaries to gitignore
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:48:05 +03:00
Pavel Emelyanov
98a9a4c326 shmem: Remove write-only fields from shmem-info
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:47:30 +03:00
Pavel Emelyanov
a1b1959dd1 shmem: Turn shmem-info into shared objects from shremap ones
We have a nasty issue with it. Current code allocates these
entries in shremap area one by one. We do NOT allocate any
OTHER entries in this region, but if we will this array will
be spoiled.

Fortunately we no longer need shmem-infos as plain array,
neither we need one in restorer. So just turn this into plain
shared objects and collect them in a list.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:47:24 +03:00
Pavel Emelyanov
b246ccb181 shmem: Move some code to shmem.c file
The struct and find routine used to be use by restorer code. Now
the former fully uses vmas and fd opened, so we can move the code
into .c file not to spoil global namespace.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:47:17 +03:00
Pavel Emelyanov
455f9b564e fd: Factor out inheriting FDs code
We have two places where we lookup the inherited-fd list
by name and dup() the descriptor found. I propose to factor
out this piece in a single inherited_fd() call. When
we will want to support inheritance for sockets or any
other files we'll simply add the inherited_fd() call
there.

I'm also thinking about moving the call to inherited_fd
into generic level, but the open_path() routine doesn't
allow to do it in a simple manner.

Also we have not yet finished issue with files-vs-inodes
mapping. Keeping all the logic in one function should
make the solution simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:46:51 +03:00
Pavel Emelyanov
8f691c40d5 fd: Mark inherit_fd_lookup_fd static
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:46:42 +03:00
Mark A. O'Neill
6d6db9e1aa tun: Small changes I needed to get criu working under 3.18.1 kernel on Centos 6.5 machine.
Signed-off-by: Mark A. O'Neill <mao@tumblingdice.co.uk>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 14:37:11 +03:00
Saied Kazemi
19ffca535c Try to determine the bind mount file for dockerinit
This patch adds code to the contrib/docker_cr.sh helper script for trying
to determine the external bind mount file for dockerinit if the user
has not explicitly specified it via the DOCKERINIT_BINARY environment
variable.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-12 13:20:06 +03:00
Andrew Vagin
769d527876 tests: add libaio to LDLIBS
Reported-by: Mr Travis
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-30 19:59:19 +03:00
Andrew Vagin
ea3e39450a scripts/travis.sh: add libaio-dev for ARM
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-30 16:30:11 +03:00
Ruslan Kuprieiev
78618b621a check: skip AIO remap error, if --ms is specified
criu check --ms results in an error on a stock fedora 21 kernel.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-30 15:38:51 +03:00
Pavel Emelyanov
549795a8c1 aio: Fix vma->start printing format on arm
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-30 15:38:25 +03:00
Andrey Vagin
4836e39256 .travis.yml: add libaio-dev
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-30 15:36:27 +03:00
Pavel Emelyanov
a25747f95f pie: Fix sizeof's printinf format
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-30 15:12:06 +03:00
Andrey Vagin
f42ba40f27 jenkins: exclude maps04 from the criu-iter job
This job does three iterations. We need to write about 0.5Gb of images
for maps04.  This is too much for our test VM and other tests start fail
due to timeout.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-26 18:17:00 +03:00
Cyrill Gorcunov
fd07bc7791 cpu: Add 'ins' mode to --cpu-cap option
In this mode we test if target cpu has all features present
in image file but do not require bit to bit match: target cpu
may be a new one with more features present.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-26 18:15:46 +03:00
Pavel Emelyanov
bbc38f3dac zdtm: Simple test for AIO ring
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-26 18:13:44 +03:00
Pavel Emelyanov
9594595096 check: Add check for remapable AIO rings
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-26 18:13:42 +03:00
Pavel Emelyanov
2694a74a00 aio: Restore AIO contexts
Restoring AIO is quite simple. Once all VMAs are put in
their places we can call io_setup() to let kernel create
the context back and then move the ring into proper place.

Another thing we should "restore" is the context ID. But
the thing is, upon ring creation kernel repots the ring
start address as this ID. And there's a patch in the -next
tree that changes the ID when we remap the ring. That
said after AIO context creation and ring remap we need
to check that the new ID is seen by the kernel.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-26 18:13:40 +03:00
Pavel Emelyanov
08c204820f aio: Dump AIO rings
When AIO context is set up kernel does two things:

1. creates an in-kernel aioctx object
2. maps a ring into process memory

The 2nd thing gives us all the needed information
about how the AIO was set up. So, in order to dump
one we need to pick the ring in memory and get all
the information we need from it.

One thing to note -- we cannot dump tasks if there
are any AIO requests pending. So we also need to
go to parasite and check the ring to be empty.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-26 18:13:36 +03:00
Pavel Emelyanov
80cf042695 x86: Add io syscalls
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-26 18:13:33 +03:00
Cyrill Gorcunov
f165bdc93c cpu: x86 -- Fix --cpu-cap=fpu handling on restore mode
Our CPU_CAP_s are bitmaps so if cpuinfo image is present
but we require only FPU to check we need to check this
bit being sole on comman line.

It was a typo in first place which caused statement to
be false always (it's not a problem though and not a
@stable candidate because with this mistake we fall
into strict match cpu mode).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-25 21:12:05 +03:00
Andrey Vagin
2fd795b61c zdtm/cwd02: avoid resolving an abs path
We may not have permissions for this.

Reported-by: Mr Jenkins
Fixes: 7dbd38dbc9 ("zdtm: set additional groups along with uids and gids")
Cc: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-25 21:10:58 +03:00
Andrey Vagin
79c4b74705 arm: fix compilation on ARMv7
/tmp/ccq2xzf8.s: Assembler messages:
/tmp/ccq2xzf8.s:5748: Error: thumb conditional instruction should be in IT block -- strexeq r1,r2,[r3]'

Cc: Alexander Kartashov <alekskartashov@parallels.com>
Cc: Ruslan Kuprieiv <kupruser@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-25 21:10:35 +03:00
Pavel Emelyanov
86c0c5fb99 proc: Allocate and get vma fstat in vma_get_mapfile
We will need to detect aio mappings soon, so this is a preparation,
that makes future patching simpler.

Also move aufs stat-ing into aufs code to keep more aufs logic in
one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-25 21:10:15 +03:00
Andrew Vagin
f4282b478a zdtm/cwd01: avoid resolving an abs path
We may not have permissions for this.

Reported-by: Mr Jenkins
Fixes: 7dbd38dbc9 ("zdtm: set additional groups along with uids and gids")
Cc: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Acked-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-24 19:15:04 +03:00
Andrey Vagin
18d40fddd6 zdtm.sh: set correct path for dump files (v3)
Don't use an uninitialized variable to create a path pattern.

v2: fix the comment
v3: don't use readlink -m, which isn't supported by busybox

Cc: Christopher Covington <cov@codeaurora.org>
Reported-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-24 19:13:17 +03:00
Andrew Vagin
7f4afef2cf arm: fix compilation on ARMv6
Cc: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Tested-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-22 17:41:33 +03:00