2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-26 03:47:35 +00:00

135 Commits

Author SHA1 Message Date
Ronny Chevalier
e5e14830ce lib/c: add missing criu_local_set_service_binary signature
Signed-off-by: Ronny Chevalier <ronny.chevalier@hp.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-22 00:13:23 +03:00
Ronny Chevalier
72dc405b3f lib/c: add const qualifier to criu_set_service_binary
service_binary is either set to a const char * (CR_DEFAULT_SERVICE_BIN)
or to a user provided char *, but there is no reason to give a char *.
Users of such function will most likely provide a const char *,
that will generate a warning.
Thus, we add the const qualifier to better represent the usage of
service_binary, and avoid such warnings.

Signed-off-by: Ronny Chevalier <ronny.chevalier@hp.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-22 00:13:23 +03:00
Cyrill Gorcunov
8aef37902c crit: Show cpuinfo image
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-18 21:07:01 +03:00
Andrei Vagin
2a027fe9d3 crit: typo fix
test/dump/zdtm/static/msgque/43/1/ipcns-msg-12.img decode fails: object of type 'NoneType' has no len()

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-14 20:22:54 +03:00
Andrei Vagin
81c37c2fc6 lib: a few fixes to be compatible with python3
All these issues was found by running test/crit-recode.py

https://github.com/checkpoint-restore/criu/issues/495

v2: drop FD_CLOEXEC for swrk descriptors
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-08 09:54:22 +03:00
Adrian Reber
a390094bd0 crit: enable python2 or python3 based crit
With this last commit of the crit with python3 series it is possible to
either use python2 or python3 with CRIU.

Now the basic build system functionality (make and make install) are
python2/python3 aware. zdtm.py and criu-coredump are still python2, but
as they are not part of 'make install' those parts have not yet been
ported from python2 to python3.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-25 00:23:00 +03:00
Adrian Reber
222ad25bed Makefiles: auto-detect python version - prefer python2
This prepares CRIT for python2/python3 compatibility by auto-detecting
the installed python version. python2 is detected first and then the
variable PYTHON is set.

By setting the variable PYTHON to python2/python3 the user can override
the auto-detection.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-25 00:23:00 +03:00
Adrian Reber
af353d0f69 crit: make crit python2/python3 compatible
Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-25 00:23:00 +03:00
Andrei Vagin
34f16a4607 cgroups: don't leak memory on a error path
CID 161693 (#1 of 1): Resource leak (RESOURCE_LEAK)
5. leaked_storage: Variable new going out of scope leaks the storage it points to.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-02-16 22:56:36 +03:00
Andrei Vagin
0d786de5f3 criu: fix gcc-8 warnings
criu/sk-packet.c:443:3: error: 'strncpy' output may be truncated
copying 14 bytes from a string of length 15
   strncpy(addr_spkt.sa_data, req.ifr_name, sa_data_size);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/img-remote.c:383:3: error: 'strncpy' specified bound 4096
equals destination size
   strncpy(snapshot_id, li->snapshot_id, PATHLEN);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/img-remote.c:384:3: error: 'strncpy' specified bound 4096
equals destination size
   strncpy(path, li->name, PATHLEN);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/files.c:288:3: error: 'strncpy' output may be truncated copying
4095 bytes from a string of length 4096
   strncpy(buf, link->name, PATH_MAX - 1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/sk-unix.c:239:36: error: '/' directive output may be truncated
writing 1 byte into a region of size between 0 and 4095
   snprintf(path, sizeof(path), ".%s/%s", dir, sk->name);
                                    ^
criu/sk-unix.c:239:3: note: 'snprintf' output 3 or more bytes
(assuming 4098) into a destination of size 4096
   snprintf(path, sizeof(path), ".%s/%s", dir, sk->name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/mount.c:2563:3: error: 'strncpy' specified bound 4096 equals
destination size
   strncpy(path, m->mountpoint, PATH_MAX);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/cr-restore.c:3647:2: error: 'strncpy' specified bound 16 equals
destination size
  strncpy(task_args->comm, core->tc->comm, sizeof(task_args->comm));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-02-13 10:16:36 +03:00
Radostin Stoyanov
a33d3739e4 Fix typos
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-02-07 21:14:26 +03:00
Andrei Vagin
ddb09e6e18 phaul: check an exit code of a page-server
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:36:15 +03:00
Andrei Vagin
767d6e1ace lib: add lib/go/src/rpc/rpc.pb.go
It is required for "go get", it can't execute any commands.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:36:14 +03:00
Andrei Vagin
e5f1a37925 phaul: use full paths for modules
It is a general practice in golang and "go get" works in this case.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:36:14 +03:00
Cyrill Gorcunov
8d16e0d0e2 crit: Show CLONE_ flags in ns image
For better readability

 | {
 |     "magic": "NS",
 |     "entries": [
 |         {
 |             "id": 10,
 |             "ns_cflag": "CLONE_NEWPID"
 |         },
 |         {
 |             "id": 8,
 |             "ns_cflag": "CLONE_NEWNET"
 |         }
 |     ]
 | }

[xemul: Removed non-ns flags from map]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-11-30 01:31:19 +03:00
Kirill Tkhai
c2a773cfeb proto: Add ns_entry description
New image format, generic for all namespaces.
Currently, it's for pid, net and user ns.

v4: Rename ns-hookup to ns.
    Make user_ns and parent generic.
v3: Move parent_id to pid and user ext

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:22:14 +03:00
Pavel Emelyanov
d9220e958b lib: Add simple Go wrappers for swrk mode
We'll need some docs :) bu the API is

criu := MakeCriu()

criu.Dump(opts, notify)
criu.Restore(opts, notify)
criu.PreDump(opts, notify)
criu.StartPageServer(opts)

where opts is the object from rpc.proto, Go has almost native support
for those, so caller should

- compile .proto file
- export it and golang/protobuf/proto
- create and initialize the CriuOpts struct

and notify is an interface with callbacks that correspond to criu
notification messages.

A stupid dump/restore tool in src/test/main.go demonstrates the above.

Changes since v1:

* Added keep_open mode for pre-dumps. Do use it one needs
  to call criu.Prepare() right after creation and criu.Cleanup()
  right after .Dump()

* Report resp.cr_errmsg string on request error.

Further TODO:

- docs
- code comments

travis-ci: success for libphaul (rev2)
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:18:53 +03:00
Andrei Vagin
008db0cb7a zdtm: run page-server via rpc
v2: typo fix
v3: run criu pre-dump via rpc
v4: don't use status-fd for rpc

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:23 +03:00
Andrei Vagin
397df9c035 lib/py: allow to execute page-server as a child process
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:23 +03:00
Cyrill Gorcunov
0b6f9c7975 build: Reused .FORCE from nmk
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:14 +03:00
Avindra Goolcharan
8e45ce4905 images.py: remove shebang
This file is not executable directly, so it should not have the shebang.

Signed-off-by: Avindra Goolcharan <aavindraa@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:14 +03:00
Cyrill Gorcunov
fc21d6fb53 crit: Add socket states decoding
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:14 +03:00
Cyrill Gorcunov
4d0fc1a496 crit: Add socket types decoding
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:14 +03:00
Cyrill Gorcunov
d4c29ab7cb crit: Add protocols decoding
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:14 +03:00
Cyrill Gorcunov
56cd56706d crit: Add more families into socket decoding
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:14 +03:00
Cyrill Gorcunov
ec273275fe crit: Add INET6 familiy
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:14 +03:00
Mike Rapoport
48675a3c7e Drop support for zero pagemap entries
The pagemap entries for pages mapped to zero pfn proved to be not useful...

travis-ci: success for revert zero pagemaps
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-16 11:47:02 +03:00
Adrian Reber
2ce576e646 crit: translate pagemap flags into strings
This translates pagemap flags into strings for easier readability.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-16 09:16:33 +03:00
Pavel Emelyanov
fe6fa3bec3 image: Introduce files.img and file_entry
There are two goals of this merge. First is to reduce the amount
of image files we generate and scan on restore. The latter is
more importaint, as even if we have no weird stuff like signalfd,
we still try to open this file. So after the merge we try to
open ~15 image files (out of ~30) less %) which is nice.

The 2nd goal is to simplify the C/R support for SCM messages.
This becomes possible with the fact, that all files we have can
be distinguished by their ID only, w/o type. This, in turn,
makes image layout for SCMs much simpler.

Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-08-09 18:51:39 +03:00
Pavel Emelyanov
c7ab0cd934 crit: Add support for chunked ghost images
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-07-18 09:34:44 +03:00
Kir Kolyshkin
4669d6330e crit: fix 'make install'
Apparently, setup.py from distutils interprets --root= option without
an argument as "--root=." and we end up with what is described
in https://github.com/xemul/criu/issues/309.

Fix is to prepend DESTDIR value (if any) to --prefix argument.

v2: fix uninstall as well
v3: same code, resent via gmail

Reported-by: Juraj Oršulić <juraj.orsulic@fer.hr>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-05-19 09:17:19 +03:00
Pavel Emelyanov
1e1d0dde26 pycriu: Dont produce zombies
When running criu_dump() with zero pid (self dump) a zombie
from the library is left underneath the running processes
and this zombie is thus written into the images.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-05-10 04:13:41 +03:00
Dmitry Safonov
057c3f2947 python: specify python2 as .py interpreter
On some distro the default python interpreter is Python 3,
which results in such errors:
>  Running zdtm/static/socket-tcp-closed.hook(--post-start)
>  make[1]: Nothing to be done for default.
>  ./socket-tcp-closed --pidfile=socket-tcp-closed.pid --outfile=socket-tcp-closed.out
>    File "zdtm/static/socket-tcp-closed.hook", line 16
>      except OSError, e:
>                    ^
>  SyntaxError: invalid syntax
>  ######### Test zdtm/static/socket-tcp-closed FAIL at hook --post-start #########
>  Running zdtm/static/socket-tcp-closed.hook(--clean)
>    File "zdtm/static/socket-tcp-closed.hook", line 16
>      except OSError, e:
>                    ^
>  SyntaxError: invalid syntax
>  Traceback (most recent call last):
>    File "zdtm.py", line 1921, in <module>
>      do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3])
>    File "zdtm.py", line 1388, in do_run_test
>      try_run_hook(t, ["--clean"])
>    File "zdtm.py", line 1053, in try_run_hook
>      raise test_fail_exc("hook " + " ".join(args))
>  __main__.test_fail_exc: <__main__.test_fail_exc instance at 0x76294468>

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-04-17 18:35:58 +03:00
Pavel Emelyanov
e77d36c375 crit: Beautify unix names recode
Unix socket name can be a string with any bytes in it. So to
print the name we use base64 encoding. Doing so doesn't allow
to see the socket name when it contains only printable chars.

So here's the custom encoding for bytes fields, that can be
used for custom conversion.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-04-11 09:01:11 +03:00
Pavel Emelyanov
5e3509ba16 crit: Decode some numbers into strings
There are several places in image files, where we store
integers, but these numbers actually mean some string.
E.g. socket families, states and types and tasks states.

So here's the (criu).dict option for such fields that
helps to convert the numbers into strings and back.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-04-11 09:01:11 +03:00
Kir Kolyshkin
f62818d9ad compel: no -r for ARM ldflags
Commit d9486bd720 ("arm/pie/build: do not produce relocatable parasite
object") removed -r from LDFLAGS used to compile criu pie. This
functionality somehow never made it to criu-dev, and was also lost
in master then compel was ported to it.

Make it work with compel.

Unfortunately it was not as simple as I initially thought, as -r flag
to ld was built into nmk. This patch removes it, and adds it to all
places that need intermediate linking.

Cc: Dmitry Safonov <dsafonov@virtuozzo.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-04-02 18:12:10 +03:00
Kir Kolyshkin
ab90777ca1 Makefiles: protect from % rules, don't rebuild
GNU make tries to rebuild any makefiles it uses. While in general it's
a good idea (and it is used e.g. in autoconf-based builds), in our case
it is not necessary, as all the makefiles are static.

More to say, as we have a few "match anything" rules for subdirectories,
Makefiles in these subdirs are also matching these rules, which leads to
excessive (re)building while a particular makefile is needed.

Protect such Makefiles with explicit (or pattern) rules, so make knows
it should do nothing to rebuild those.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-15 09:36:08 +03:00
Kir Kolyshkin
85b04c8bfd Makefiles: nuke $(SRC_DIR)
As all builds are done from top source dir, there is no need
to have SRC_DIR.

Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-15 09:36:08 +03:00
Kir Kolyshkin
1fe09eb358 Makefiles: move -Wa,--noexecstack out of CFLAGS
The problem is, -Wa is a flag for assembler, but CFLAGS are also used
to generate dependencies, and clang complains loudly when it is used
for deps:

> >   DEP      compel/arch/x86/plugins/std/syscalls-64.d
> >  clang-3.8: error: argument unused during compilation:
> > '-Wa,--noexecstack'

This patch moved the noexecflag from assembler to linker. I am not
100% sure but the end result seems to be the same.

This fixes dependency generation when using clang instead of gcc.

I surely have done my research before proposing this change, and
I have tested this change as good as I could.
Sorry, I should have provided more background in the commit message.
Here it goes.

There are a few ways to have non-executable stack:
1. mark the assembler source file (.S) with .section
.note.GNU-stack,"",%progbits
2. pass the -Wa,--noexecstack to compiler
3. pass the -z execstack to linker

All three ways are fine, let's see them in greater details.

Some people say (1) is the best way, but we have way too many
.S files now (23 of them, to be exact). Anyway, I can certainly do it
this way if you like, just let me know. It would look like this:

    --- a/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S
    +++ b/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S
    @@ -3,6 +3,8 @@
     * that are not implemented in the AArch64 Linux kernel
     */

    +.section .note.GNU-stack,"",%progbits
    +
     ENTRY(sys_open)
     mov x3, x2
     mov x2, x1

Way (2) is what is currently used. Unfortunately it breaks dependency
generation with clang. One way to fix it would be to filter-out the bad
flag when we're generating deps. I tried experimenting with
$(filter-out) function in Makefiles today but it's complicated and I failed
to make it work.

Way (3) is what this commit offers. It seem to work fine while being
the least intrusive.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-15 00:05:55 +03:00
Kir Kolyshkin
2a9d9c6615 lib Makefiles: integrate
Our whole system of Makefiles are integrated from top to bottom,
meaning:

 1. The paths in sub-makefiles are relative to the top source dir.
 2. Sub-makefiles are executed via make $(build)=<SUBDIR> <TARGET>

For some reason, makefiles under lib/ are the exclusion. Let's fix it.

Side effect: you can now build any individual target under lib/,
for example, "make lib/c/libcriu.so" works.

[v2: use the .FORCE, thanks to dsafonov@]

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-06 20:44:07 +03:00
Pavel Emelyanov
9fe7ccca6e py: Fix resp.errno access
There's no such field in resp, only cr_errno

travis-ci: success for py: Fix resp.errno access
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Andrei Vagin <avagin@virtuozzo.com>
2016-12-21 11:23:02 +03:00
Cyrill Gorcunov
d647f47f20 criu: install -- Make INCLUDEDIR not carry criu directory
INCLUDEDIR gonna be used in compel.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-12-21 11:22:24 +03:00
Pavel Tikhomirov
d1be199765 Add --weak_sysctl CLI option to RPC and lib
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-12-05 23:34:54 +03:00
Raghavendra Prabhu
af74019d66 Ensure the install process is PEP-394 compliant.
The installation needs to use python2, but it uses python in the
Makefile which fails later with syntax error
(since it is written for python2).

As per PEP-394 - https://www.python.org/dev/peps/pep-0394/ -,
'all distributions should ensure that python refers to the same target
as python2 .', hence this change.

Therefore, python2 is used by default in lib/Makefile, though
this can be overriden with PYTHON_BIN.

Tested with:

a) PYTHON_BIN=python2 make install
b) make install

c) export PYTHON_BIN=python2
   make test

Signed-off-by: Raghavendra Prabhu <me at rdprabhu dot com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-12-05 11:49:19 +03:00
Ruslan Kuprieiev
c4f4e6c926 lib: add external support
It is already present in rpc, so lets add it to libcriu too.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-11-12 11:06:21 +03:00
Ruslan Kuprieiev
4f329dd4b2 lib: add inherit_fd
It is already present in CLI and RPC, so libcriu should reflect it too.

travis-ci: success for lib: add inherit_fd
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Tycho Andersen
f3e412f900 python lib: rename rpc.py to rpc_pb2.py
Unfortunately, newer versions of protobuf check that the file suffix ends
in _pb2.py:

sudo ./zdtm.py run -t zdtm/static/apparmor_stacking
Traceback (most recent call last):
  File "./zdtm.py", line 23, in <module>
    import criu as crpc
  File "/home/ubuntu/criu/test/criu.py", line 12, in <module>
    import rpc
  File "/home/ubuntu/criu/test/rpc.py", line 36, in <module>
    type=None),
  File "/usr/lib/python2.7/dist-packages/google/protobuf/descriptor.py", line 652, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors should not be created directly, but only retrieved from their parent.

v2: fix up the clean target, and remove some comments that were about the
    old rename

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-10 12:49:28 +03:00
Kir Kolyshkin
9e2ce61cac Makefile nitpicks
1. As __nmk_dir already ends with a slash, there's no need
   for an extra one.

2. No need to include macro.mk into criu/Makefile -- nothing it defines
   is used from there.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-05 13:11:26 +03:00
Kir Kolyshkin
40edd7eff5 lib/c/criu.h: rm explicit numbering of enum elements
C standard specifies that the first enum element is 0 and the next ones
are +1 to a previous element (C90, "3.5.2.2 Enumeration
specifiers").
Therefore, there is no need to explicitly specify element values.

The explicit initializers were added in the first commit introducing
this enum (commit 46e8aee).

While at it, let's also add a comma after the last element, for any
future patch adding more elements to look better.

No functional change.

Cc: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-09-26 15:42:43 +03:00
Adrian Reber
09a2afe07e criu: almost fix building on Alpine Linux
It seems that the different libc (musl) which Alpine Linux uses produces
different errors than the usual glibc. This patch fixes most include
errors. Two errors are not yet resolved on Alpine Linux's libc (musl):

 * proc_parse.c: In function 'parse_posix_timers':
   proc_parse.c:2125:34: error: 'SIGEV_THREAD_ID' undeclared (first use in this function)
        timer->spt.it_sigev_notify = SIGEV_THREAD_ID;

   proc_parse.c:2125:34: note: each undeclared identifier is reported only once for each function it appears in

   Seems difficult to fix as including <linux/signal.h>, which provides
   this #define, generates more different error messages related to
   time.h and linux/time.h collisions. It is not yet clear if additional
   guards would help in the header files.

 * fsnotify.c: In function 'open_by_handle':
   fsnotify.c:107:9: error: implicit declaration of function 'open_by_handle_at' [-Werror=implicit-function-declaration]
     return open_by_handle_at(fd, arg, O_PATH);

   The function open_by_handle_at() is not provided by Alpine Linux's
   libc (musl).

This patch resolves the following errors/warnings and has been tested on
RHEL7(x86_64/powerpc64le) and Fedora 24:

cr-service.c: In function 'cr_service':
cr-service.c:1082:26: error: passing argument 2 of 'accept' from incompatible pointer type [-Werror=incompatible-pointer-types]
   sk = accept(server_fd, &client_addr, &client_addr_len);
                        ^
In file included from /usr/include/fortify/sys/socket.h:20:0,
                 from cr-service.c:11:
/usr/include/sys/socket.h:301:5: note: expected 'struct sockaddr * restrict' but argument is of type 'struct sockaddr_un *'
 int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
     ^
cc1: all warnings being treated as errors

files.c: In function 'open_transport_fd':
files.c:845:19: error: passing argument 2 of 'bind' from incompatible pointer type [-Werror=incompatible-pointer-types]
  ret = bind(sock, &saddr, sun_len);
                   ^
In file included from /usr/include/fortify/sys/socket.h:20:0,
                 from files.c:12:
/usr/include/sys/socket.h:298:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *'
 int bind (int, const struct sockaddr *, socklen_t);
     ^
cc1: all warnings being treated as errors

In file included from fsnotify.c:18:0:
/usr/include/sys/poll.h:1:2: error: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Werror=cpp]
 #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
  ^
cc1: all warnings being treated as errors

In file included from /root/criu/criu/include/timerfd.h:7:0,
                 from /root/criu/criu/include/restorer.h:18,
                 from arch/x86/crtools.c:16:
/root/criu/criu/include/files.h:43:14: error: field 'stat' has incomplete type
  struct stat stat;

In file included from arch/x86/vdso-pie.c:6:0:
/root/criu/criu/include/syscall.h:22:66: error: unknown type name 'loff_t'
 extern long sys_pread (unsigned int fd, char *buf, size_t count, loff_t pos) ;
                                                                  ^
/root/criu/criu/include/syscall.h:83:31: error: unknown type name 'clockid_t'
 extern long sys_timer_create (clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id
                               ^
/root/criu/criu/include/syscall.h:88:38: error: unknown type name 'clockid_t'
 extern long sys_clock_gettime (const clockid_t which_clock, const struct timespec *tp) ;
                                      ^

In file included from netfilter.c:5:0:
/usr/include/wait.h:1:2: error: #warning redirecting incorrect #include <wait.h> to <sys/wait.h> [-Werror=cpp]
 #warning redirecting incorrect #include <wait.h> to <sys/wait.h>
  ^
cc1: all warnings being treated as errors

pie/restorer.c: In function '__export_restore_task':
pie/restorer.c:1276:23: error: 'LOCK_EX' undeclared (first use in this function)
   ret = sys_flock(fd, LOCK_EX);
                       ^
pie/restorer.c:1276:23: note: each undeclared identifier is reported only once for each function it appears in
pie/restorer.c:1310:23: error: 'LOCK_UN' undeclared (first use in this function)
   ret = sys_flock(fd, LOCK_UN);
                       ^

sk-unix.c: In function 'open_unixsk_standalone':
sk-unix.c:1169:19: error: passing argument 2 of 'connect' from incompatible pointer type [-Werror=incompatible-pointer-types]
   if (connect(sk, &addr, sizeof(addr.sun_family))) {
                   ^
In file included from /usr/include/fortify/sys/socket.h:20:0,
                 from sk-unix.c:1:
/usr/include/sys/socket.h:299:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *'
 int connect (int, const struct sockaddr *, socklen_t);
     ^
cc1: all warnings being treated as errors

c/criu.c: In function 'criu_local_set_parent_images':
c/criu.c:169:26: error: implicit declaration of function 'strdup' [-Werror=implicit-function-declaration]
  opts->rpc->parent_img = strdup(path);

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-07-09 22:04:26 +03:00