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

15 Commits

Author SHA1 Message Date
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
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
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
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
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
Adrian Reber
ed8fecd12d criu: add RPC interface for skip in-flight connections
For the previously added option to skip in-flight connections this adds
that option to the RPC interface. The skip in-flight connections is also
described in criu.txt.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:59 +03:00
Nikita Spiridonov
788a74cecc rpc: Add interface for @timeout option
Needed for container migration, where arguments are
set via p.haul as rpc request.

Signed-off-by: Nikita Spiridonov <nspiridonov@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:27 +03:00
Cyrill Gorcunov
85578bd5e8 rpc: Add interface --freeze-cgroup option
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Cyrill Gorcunov
7e2f7296bd cg: rpc -- Fix typos for custom cgroup props engine
Seems @rpc-> part has been sneaked out (forgot to
push into index), as result it built fine locally,
but not when applied from the patch.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:05:53 +03:00
Cyrill Gorcunov
900e71cbec cg: rpc -- Add bindings for custom cgroup props engine
For handling  --cgroup-props, --cgroup-props-file and
--cgroup-dump-controller from RPC interface.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:05:52 +03:00
Pavel Emelyanov
3cffd523e4 Revert "seccomp: add a --no-seccomp option to disable dumping seccomp"
This reverts commit a98014f306be4b4fefdf01af31e1efa5d83e5e4f.

As per Saied Kazemi, actually dump works without seccomp support
from the kernel on non-seccomped tasks. The only problem was with
criu check, but this would be addressed separately.

Reverting the commit not to burden the API with (yet) unneeded stuff.

Conflicts:
	lib/c/criu.h
2016-02-20 13:35:47 +03:00
Tycho Andersen
a98014f306 seccomp: add a --no-seccomp option to disable dumping seccomp
Sometimes we may want to use CRIU on older kernels which don't support
dumping seccomp state where we don't actually care about the seccomp state.
Of course this is unsafe, but it does allow for c/r of things using
seccomp on these older kernels in some cases. When the task is in
SECCOMP_MODE_STRICT or SECCOMP_MODE_FILTER with filters that block the
syscalls criu's parasite code needs, the dump will still fail.

Note that we disable seccomp by simply feigning that we are in mode 0. This
is a little hacky, but avoids distributing ifs throughout the code and
keeps them in this one place.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-17 13:46:55 +03:00
Cyrill Gorcunov
da0eb1483b build: Move C and Python libraries into lib
Both CRIU library and CRIT python data are moved into
lib/c and lib/py.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-15 15:32:39 +03:00