2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 21:07:43 +00:00

51 Commits

Author SHA1 Message Date
Kir Kolyshkin
94b09be23a cr_service(): don't use pr_perror()
Since sd_listen_fds() doesn't set errno when returning a value > 1,
it doesn't make sense to use pr_perror(). Use pr_err() instead.

While at it, remove the period from the log message.

[v2: fix function names]

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:08:21 +04:00
Pavel Emelyanov
c79751171f service: Add coment about cr_dump_task() scripts code propagation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:24:52 +04:00
Ruslan Kuprieiev
fba791a607 service: fix bug, when root_item isn't initialized
If restore fails on early stage(like no images in directory), then root_item
might be uninitialized, so when we are trying to send response with root_item->pid
criu crashes.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:18:00 +04:00
Ruslan Kuprieiev
003cfcae19 service: fix bug, when criu reports success on dump fail
cr_dump_tasks() may return not only -1 on fail.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:17:53 +04:00
Ruslan Kuprieiev
a1e7407397 service: move constants to cr-service-const.h
Such constants as CR_MAX_MSG_SIZE and CR_DEFAULT_SERVICE_ADDRESS are need to be used in both service and lib.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:26:10 +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
Kir Kolyshkin
bf5a8e13e1 cr_service(): don't exit(-1)
We should exit(1) on error, exit(0) on success.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:36:21 +04:00
Kir Kolyshkin
b744883e42 cr_service(): close fd on error
... and don't return -1.

This is a missing part from commit 3477223.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:36:14 +04:00
Shawn Landden
2e15e4da92 systemd socket activation support
Makes the criu RPC socket socket-activated with
systemd [1], meaning that systemd will create and listen to
the UNIX socket /var/run/criu-srvice.socket
on behalf of criu until a connection comes in, when it will
then pass control of the socket, along with the first connection
over to a newly spawned criu daemon.

This is similar to inetd, but criu stays around after getting
started, listening itsself on the socket.

[1] http://0pointer.de/blog/projects/socket-activation.html

v2: stripped down sd-daemon.[ch]
    moved units to scripts/sd

v3: stripped down further by removing unneeded includes

Signed-off-by: Shawn Landden <shawn@churchofgit.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 09:58:50 +04:00
Ruslan Kuprieiev
07e153fc4c service: set success to true before exit
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-05 12:05:46 +04:00
Ruslan Kuprieiev
2e8ff1a22a v2 service: don't send dump response in case of self-dump without leave_running
Currently we have a bug: if no leave_running is set in request, service won't send dump response. We must not send response only if it was a self-dump request and no leave_running option was set.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-02 19:50:44 +04:00
Ruslan Kuprieiev
b49d096016 service: set CHECK type on check response
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-22 09:29:12 +04:00
Pavel Emelyanov
c3b9448cf7 pidfile: Don't push opts.pidfile as write_pidfile arg
opts are criu-wide available.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-20 14:26:41 +04:00
Ruslan Kuprieiev
0b5b2f9906 service: Add support for check request
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-20 14:16:44 +04:00
Ruslan Kuprieiev
b1a197f0b8 page-server/service: do not chdir / when going daemon
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-15 21:38:44 +04:00
Ruslan Kuprieiev
dc80d6f125 log: get rid of LOG_DIR_FD_OFF and opening cwd in log_init()
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-15 21:38:41 +04:00
Ruslan Kuprieiev
127637bc49 image: add dir parameter to open_image_dir()
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-15 21:38:40 +04:00
Andrey Vagin
dd407dd04e hdrs: minor cleaup
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-07 15:13:50 +04:00
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
1cb945cafe crtools: don't include util.h in crtools.h
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 15:42:12 +04:00
Ruslan Kuprieiev
59c43e481e v3 service: SIGCHLD handler
Hi!

Now we're ignoring SIGCHLD from forked children.
This patch provides SIGCHLD handler, that will wait for child and write some
information about it's exit status to logfile.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-01 14:32:03 +04:00
Ruslan Kuprieiev
95e93d6c9a service: reinit opts in cr_service_work()
These are inherited from parent on fork(), thus need to put them in
clean state.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-31 20:00:31 +04:00
Pavel Emelyanov
ebb4a1bf60 service: Go to daemon with detached terminal and cwd
Logs are put into dedicated logfd, cwd is not used as well.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-11 17:59:21 +04:00
Pavel Emelyanov
80b1da7fb6 service: Add comment why we do detached restore on RPC request
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 23:20:33 +04:00
Ruslan Kuprieiev
ba196e6358 service: treat restore request properly
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 20:16:51 +04:00
Ruslan Kuprieiev
dbced2f013 log: one default log filename
Lets use one default log filename. User can set if in request, if needed.
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 20:16:38 +04:00
Pavel Emelyanov
b4c8c5ae32 security: Also save gid of user requesting for C/R
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 15:51:09 +04:00
Ruslan Kuprieiev
398705d4cb rpc: rename criu_dump_req to criu_opts
Lets rename CriuDumpReq to CriuOpts, for the sake of readability and to
avoid coping code for restore mechanism, as CriuDumpReq and
CriuRestoreResp would have almost the same fields. Also, it would be
easier to introduce other types of requests.

Signed-off-by: Ruslan Kuprieiev <kurpuser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 16:04:11 +04:00
Ruslan Kuprieiev
4d80f502e8 v2 rpc: add log_file field to opts, add defaults toi log.h and use them where needed
[xemul: Simplified !log_file case and renumbered .proto fields]

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 16:01:44 +04:00
Pavel Emelyanov
4b9b7953dd service: Make default (not set) service ino == -1
Zero is bad for checks, as peer-less sockets have such.
BUG introduced in cfe72ab7 :(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 09:44:29 +04:00
Pavel Emelyanov
2fe5884df3 service: Remove empty cr_service_client
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:18:44 +04:00
Pavel Emelyanov
91389f8782 security: Introduce (rather basic) security restrictions for C/R
Right now we have an ability to launch the C/R service from root
and execure dump requests from unpriviledged users. Not to be bad
guys, we deny dumping tasks belonging to user, that cannot be
"watched" (traced, read /proc, etc.) by the dumper.

In the future we will use this "engine" when launched with suid
bit, and (probably) will have more sophisticated policy.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:16:17 +04:00
Pavel Emelyanov
cfe72ab77a service: Put service sk inode into separate variable
I'm about to get rid of service state struct.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:06:53 +04:00
Pavel Emelyanov
14559435f5 service: Sanitize service-child code-flow
* Close fd only once at the end
* Close listener socket

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:59:33 +04:00
Pavel Emelyanov
0acc2624d4 service: Remove sk fd from service state struct
This fd is an internal thing of the service. Remove it from
externally available structure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:54:50 +04:00
Pavel Emelyanov
0521367f22 service: Remove actually unused pid variable from service state
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:52:18 +04:00
Pavel Emelyanov
9bc82f4910 rpc: Send EMPTY message with success == fail in case of unsupported request
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:49:31 +04:00
Ruslan Kuprieiev
3f9478d68c service: check errors of xmalloc
Original-patch-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:18:51 +04:00
Ruslan Kuprieiev
bc5828c111 service: don't leak a client socket if fork failed
Original-patch-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:17:33 +04:00
Andrey Vagin
c861f61e0c service: exit if accept() returned an error
I don't know a reason, when accept() fails once and then goes back to
normal work.

Cc: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:12:55 +04:00
Andrey Vagin
3477223068 service: set one exit point (v2)
v2: remove exit()

Cc: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:11:56 +04:00
Pavel Emelyanov
bd90e9887c service: move worker's code in a separate function
Original-patch-by: Andrey Vagin <avagin@openvz.org>
Original-patch-by: Ruslan Kuprieiev <kupruser@gmail.com>

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 14:37:56 +04:00
Ruslan Kuprieiev
c90b58d855 service: change a few "puts" with "pr_perror"
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 14:31:29 +04:00
Pavel Emelyanov
44faa25d9d rpc: Mark that dump-resp restore is in the message
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-17 00:50:03 +04:00
Ruslan Kuprieiev
4eb2872b27 v2 crtools: write pidfile, when service/page server is run as daemon and "--pidfile" is set
When service/page server becomes daemon, we may need to know it's pid.

Signed-off-by: Ruslan Kuprieiev<kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:45:01 +04:00
Pavel Emelyanov
c6b79bd35f service: Don't forget to send dump-failed message
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:41:37 +04:00
Pavel Emelyanov
5f47e0a67f service: Simplify dump-responce sending
We need 2 parameters only to form it properly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:40:04 +04:00
Pavel Emelyanov
e866b7c043 rpc: Split rpc req-s from rpc-resps
Now we don't have generic criu_msg thing -- instead, we have
explicit request (with per-type args) and explicit responce
(yet again -- with per-type args).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:36:12 +04:00
Ruslan Kuprieiev
98b5541492 v2 rpc: change some "required" fields to "optional"
The most of fields are to be changed to "optional", because they are
optional in fact.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:21:13 +04:00
Ruslan Kuprieiev
8fddfd2ff4 crtools: Add cr_service meat
The need in service is described at http://criu.org/Self_dump

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-13 15:53:06 +04:00