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

60 Commits

Author SHA1 Message Date
Andrey Vagin
99bb419df1 image: don't leak a file descriptor
CID 1141015 (#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:59:34 +04:00
Tikhomirov Pavel
632798b789 v3 Fix for open_pages_image_at to read if opened with O_RDWR
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:50:47 +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
Ruslan Kuprieiev
486cad37cc image: Open parent image dir with -at calls
After fixes with -W option we've changed the cwd at the
time parent images are opened. Use the -at syscall to
proerly access ones.

[ Cleanup and comment from xemul@ ]

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-18 13:22:10 +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
Cyrill Gorcunov
8f64a14a03 headers: Move fcntl related data to include/fcntl.h
fcntl data is arch independent, so move it out of include/asm/type.h

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-14 22:13:10 +04:00
Andrey Vagin
6f0a7ed332 hdrs: delete extra headers from image.c
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-07 15:13:25 +04:00
Andrey Vagin
a434e7f075 crtools: move pid_rst_prio to pid.h
crtools.h is too heavy to be included in many sources

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:18:12 +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
1300cf4915 crtools: move all stuff about fdset in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 15:24:48 +04:00
Pavel Emelyanov
0327d5511b fdset: Beautify fdset opening
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:39:52 +04:00
Andrey Vagin
07930a8df4 ns: replace pid on id in per-namespace files
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:17:04 +04:00
Andrey Vagin
51fca3806c namespaces: remove unused code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:11:53 +04:00
Andrey Vagin
8a23c3106d images: export cr_fdset_open
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:09:56 +04:00
Pavel Emelyanov
b18fb09eb9 show: Replace one-line show_foo calls with args array
We have generic do_pb_show() call and tons of show_foo
routines, that just call one with proper args. Compact
the code by putting the args into array and calling
the do_pb_show() in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-24 04:00:32 +04:00
Cyrill Gorcunov
17b0a47b98 image: Move image descriptors to own files
Move image object descriptors to own image-desc
file(s). This allow to reuse the code in other tools.
I had to move show declarations to cr-show.h as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-28 22:12:06 +04:00
Cyrill Gorcunov
a49325b524 protobuf: Prepare scaffolds for procfs NS entries
[ xemul: rename pb.cflag -> pb.ns_cflag ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:37:00 +04:00
Libo Chen
bd9b052b3f image: potential fd leak in err case
without this patch, fd will not be freeed

* Changelog from v1:
	* just free fd, no crt.ids

Signed-off-by: Libo Chen <libo.chen@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-17 15:06:36 +04:00
Pavel Emelyanov
d416e6a135 mem-snap: Redefine CLI options for mem snapshot
They are not documented, thus OK for now. Two options --
* one to specify where the parent images are
* one to reset dirty memory tracking

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:04:57 +04:00
Pavel Emelyanov
d770f4ef23 stats: Protobuf file introduction introduction
We'll have one more "image" file generated by dump and (surprisingly)
restore commands -- the stats one. It will contain in a single pb
object all the statistics collected by dump/restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:50:15 +04:00
Kir Kolyshkin
3e8b82d367 Change crtools to criu in comments
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-10 11:02:27 +04:00
Pavel Emelyanov
add21b75c9 show: Remove options args from ->show callback
This thing is global, we can address one explicitly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 00:23:42 +04:00
Pavel Emelyanov
60fc6abfd7 cr: Preparations for snapshot
1. Directory with images may have a "parent" symlink pointing to the
   place where the previous snapshot is
2. Each pagemap will have "in_parent" bit, which means, that the
   pages for this pagemap entry are not in the respective page.img
   but in parent
3. New --leave-running option to use with --snapshot not to kill
   tasks after snapshot

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-12 19:45:15 +04:00
Pavel Emelyanov
6ff0edadcd img: Open images "at" functionality
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-12 19:45:03 +04:00
Pavel Emelyanov
5cae819d8c img: Get rid of open_image_ro helper
O_RSTR flag should be used instead for regular open_image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-09 19:22:21 +04:00
Pavel Emelyanov
a6b13b386c rlim: The rlimit images should be per-pid
It's a stupid mistake which resulted in all tasks share
the rlimits on restore :(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-29 19:40:23 +04:00
Pavel Emelyanov
cbf0ba9f48 inventory: Kill inventory.img file in case of failed dump
This will result in more sane error in case restore is launched
on such semi-complete images.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 16:16:25 +04:00
Pavel Emelyanov
421d46f79e pages: Accept pages images from versions v0.4 and below
After reworkring the way pagemap is stored the backward compatibility
was not preserved for patches simplicity. Time to return it back.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 13:12:02 +04:00
Andrey Vagin
dda97cf711 crtools: add constants for a netlink image
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-26 00:23:11 +04:00
Andrey Vagin
84176c0805 crtools: add image contants for pending signals (v2)
v2: rename images

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 23:43:36 +04:00
Cyrill Gorcunov
f3e5fd7155 ids: Don't forget to setup task state in write_img_inventory
Need to have proper fake-item state to make this code work ok:

get_task_ids
if (item->state != TASK_DEAD) {
	ret = dump_task_kobj_ids(item);
	if (ret)
		goto err_free;

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 21:24:48 +04:00
Cyrill Gorcunov
8dd32ad018 image: Fixup error paths in check_img_inventory
- Free unpacked PB data
 - Close file descriptor

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 19:38:57 +04:00
Pavel Emelyanov
d36480ed05 mem: Raise the page images IDs base for page server
Currently shmem generates page images in parallel
with page server and IDs may intersect. Fix this by
making page server create larger IDs.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:28:38 +04:00
Pavel Emelyanov
8801f59615 mem: Protobuf format for page dumps
Since now we drain pages out of parasite, we can invent any format for
page dumps. Let is be ... prorobuf one! :)

Another thing to keep in mind, is that we're about to use splices and
implement iterative migration, so it's better to have actual pages be
page-aligned in the image.

And -- backward compatibility. That said the new format is:

1. pagemap-... file which contains a header (currently with a ID of
   the image with pages, see below) and an array of <nr_pages:vaddr>
   pairs. The first value means "how many pages to take from the
   file with pages (see below)" and the second -- where in the task
   address space to put them. Simple.

2. pages-... file which containes only pages one by one (thus aligned
   as we want).

This patch breaks backward compatibility (old images with pages wil
be restored and then crash). Need to do it before v0.5 release.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:41 +04:00
Pavel Emelyanov
792bf0c494 cr: Fix namespaces restore from older images
In old images we had no clue whether the root task is to be
created in new namespaces. Remember using the --namespaces
option for explicitl specification of this fact.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:26 +04:00
Pavel Emelyanov
a46831aee9 cr: Detect namespaces presence automatically
Introduce the current_ns_mask variable, that collects info about
which namespaces tasks being dumped and to be restored live in.

For simlicity all tasks are supposed to live in one set of spaces.
This should be fixed eventually.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:10 +04:00
Pavel Emelyanov
1a60975622 img: Save crtools process IDs in inventory
On restore we'll need to know whether the root task should be
cloned in new set of namespaces. It's natural to do it by
comparing root ids with some "other-world" IDs.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:02 +04:00
Qiang Huang
de54cd4385 crtools: add image contents for filelocks
Some contents needed by filelock's image.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:40:00 +04:00
Pavel Emelyanov
fd72e27d90 inventory: Show this image with standard pb showers
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-15 23:16:34 +04:00
Cyrill Gorcunov
f385d32da5 image: fanotify -- Add scaffold code for fanotify objects
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-15 18:34:32 +04:00
Cyrill Gorcunov
b724096f0f fsnotify: Rename inotify files to fsnotify
We will be handling both inotify and fanotify
objects here thus to make less confusion rename
the files to fsnotify.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-15 18:34:26 +04:00
Andrey Vagin
d50c786c7e files: dump fdinfo per files_id instead of pid
A few processes can share one fdtable.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:44 +04:00
Andrey Vagin
20b5ed916f crtools: put kobj-ids into separate image file (v2)
It is read together with pstree items for checking what kind of
resources should be shared. Core is too big for reading it in
this place.

v2: fix check_core

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:39 +04:00
Andrey Vagin
4ea6214391 crtools: add ability to create and close a service fd (v3)
A service fd should be created, otherwise get_service_fd returns -1.

This patch removes this functionality from other subsystems and
allows to clone service descriptors.

v2: rename open_service_fd to install_service_fd
v3: two patches were merged for bisecting

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:37 +04:00
Pavel Emelyanov
748be83181 cr: Support rlimits
Dump the with "new" prlimit syscall that works on arbitrary pid.

Restore is done in restorer _after_ mappings mixup and _before_
caps drop to make it set any max value.

The RLIM_INFINITY is handled explicitly to help future 64<->32
bits migration.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-10 20:08:38 +04:00
Cyrill Gorcunov
a365befaea tty: Add show method
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:55 +04:00
Cyrill Gorcunov
89a7a45d37 tty: Add checkpoint/restore for unix terminals v6
Usually the PTYs represent a pair of links -- master peer and slave
peer. Master peer must be opened before slave. Internally, when kernel
creates master peer it also generates a slave interface in a form of
/dev/pts/N, where N is that named pty "index". Master/slave connection
unambiguously identified by this index.

Still, one master can carry multiple slaves -- for example a user opens
one master via /dev/ptmx and appropriate /dev/pts/N in sequence.
The result will be the following

master
`- slave 1
`- slave 2

both slave will have same master index but different file descriptors.
Still inside the kernel pty parameters are same for both slaves. Thus
only one slave parameters should be restored, there is no need to carry
all parameters for every slave peer we've found.

Not yet addressed problems:

- At moment of restore the master peer might be already closed for
  any reason so to resolve such problem we need to open a fake master
  peer with proper index and hook a slave on it, then we close
  master peer.

- Need to figure out how to deal with ttys which have some
  data in buffers not yet flushed, at moment this data will
  be simply lost during c/r

- Need to restore control terminals

- Need to fetch tty flags such as exclusive/packet-mode,
  this can't be done without kernel patching

[ avagin@:
   - ideas on contol terminals restore
   - overall code redesign and simplification
]

v4:
 - drop redundant pid from dump_chrdev
 - make sure optional fown is passed on regular ptys
 - add a comments about zeroifying termios
 - get rid of redundant empty line in files.c

v5 (by avagin@):
 - complete rework of tty image format, now we have
   two files -- tty.img and tty-info.img. The idea
   behind to reduce data being stored.

v6 (by xemul@):
 - packet mode should be set to true in image,
   until properly fetched from the kernel
 - verify image data on retrieval

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:54 +04:00
Andrey Vagin
58e22f31fc mount: Add support of tmpfs (v3)
When dumping a tmpfs mount we need to take its contents with us.
So, use tar for it and put it into the image dir.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 19:51:22 +04:00
Andrey Vagin
d0fd98c9fc show: don't show RAW images in show_all
If an image isn't specified, crtool shows content of all images.
Now crtools aborts in this case due to BUG_ON(1) in show methods
for raw images. I sugget to skip such images.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 16:22:32 +04:00
Pavel Emelyanov
fc7071d05e net: Packet sockets basic support
Support only basic packet socket functionality -- create and bind.
This should be enough to start testing dhclient inside container.
Other stuff (filter, mmaps, fanouts, etc.) will come later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 16:17:41 +04:00