2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

33 Commits

Author SHA1 Message Date
Adrian Reber
615ccf98cf crit: do not crash on aarch64 doing 'crit x ./ rss'
Running 'crit x ./ rss' on aarch64 crashes with:

    File "/home/criu/crit/crit/__main__.py", line 331, in explore_rss
      while vmas[vmi]['start'] < pme:
            ~~~~^^^^^
  IndexError: list index out of range

This adds an additional check to the while loop to do access indexes out
of range.

Signed-off-by: Adrian Reber <areber@redhat.com>
2024-09-19 15:23:42 -07:00
Radostin Stoyanov
4f15fe8c59 make: improve check for externally managed Python
Move PYTHON_EXTERNALLY_MANAGED and PIP_BREAK_SYSTEM_PACKAGES
into Makefile.install to avoid code duplication. In addition, add
PIPFLAGS variable to enable specifying pip options during installation.
This is particularly useful for packaging, where it is common for `pip install`
to run in an environment with pre-installed dependencies and without internet
access. In such environment, we need to specify the following options:

    --no-build-isolation --no-index --no-deps

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2024-09-11 16:02:11 -07:00
Radostin Stoyanov
0b62f4267a lib: use separate packages for pycriu and crit
Newer versions of pip use an isolated virtual environment when building
Python projects. However, when the source code of CRIT is copied into
the isolated environment, the symlink for `../lib/py` (pycriu) becomes
invalid. As a workaround, we used the `--no-build-isolation` option for
`pip install`. However, this functionality has issues in some versions
of PIP [1, 2]. To fix this problem, this patch adds separate packages
for pycriu and crit, and each package is installed independently.

[1] https://github.com/pypa/pip/pull/8221
[2] https://github.com/pypa/pip/issues/8165#issuecomment-625401463

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2023-11-27 16:47:16 -08:00
Radostin Stoyanov
61d9cf6f90 crit/setup.py: use __version__ from pycriu
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2023-10-22 13:29:25 -07:00
Radostin Stoyanov
376f3d1800 crit: add requirements.txt for pip>=20.1
When building with pip version 20.0.2 or older, the pip install
command creates a temporary directory and copies all files from
./crit. This results in the following error message:

    ModuleNotFoundError: No module named 'pycriu'

This error appears because the symlink 'pycriu' uses a relative path
that becomes invalid '../lib/py/'.

The '--no-build-isolation' option for pip install is needed to enable
the use of pre-installed dependencies (e.g., protobuf) during build.

The '--ignore-installed' option for pip is needed to avoid an error when
crit is already installed. For example, crit is installed in the GitHub
CI environment as part of the criu OBS package as a dependency for
podman.

Distributions such as Arch Linux have adopted an externally managed
python installation in compliance with PEP 668 [1] that prevents pip
from breaking the system by either installing packages to the system or
locally in the home folder. The '--break-system-packages' [2] option
allows pip to modify an externally managed Python installation.

[1] https://peps.python.org/pep-0668/
[2] https://pip.pypa.io/en/stable/cli/pip_uninstall/

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2023-10-22 13:29:25 -07:00
Radostin Stoyanov
f5d06571c5 crit: drop python 2 support
This patch reverts changes introduced with the following commits:

4feb07020dedbf845fc00268d8ca02f4645641cd
crit: enable python2 or python3 based crit

b78c4e071a42ebe34aac82fa0711df07ed375e2b
test: fix crit test and extend it

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2023-10-22 13:29:25 -07:00
Radostin Stoyanov
7f0f07599a crit: fix compatibility with Python 3.12
Python 3.12 includes a few breaking changes, such as the removal of the
distutils module [1] and the deprecation of `setup.py install` in
favour of pip install [2]. This patch updates the installation script
for crit to reflect these changes by replacing the use of
`setup.py install` with `pip install` and `distutils` with
`setuptools`. In addition, a minimal pyproject.toml file has
been added as it is required by the new version of pip [3].

It is worth noting that with this change we are switching from the egg
packaging format to wheel [4] and add pip as a build dependency.

[1] https://www.python.org/downloads/release/python-3120a2/
[2] https://github.com/pypa/setuptools/pull/2824
[3] https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/
[4] https://packaging.python.org/en/latest/discussions/wheel-vs-egg/

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2023-04-15 21:17:21 -07:00
Adrian Reber
4feb07020d 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-07-09 18:25:16 +03:00
Adrian Reber
98cb5c627d crit: make crit python2/python3 compatible
Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-07-09 18:25:16 +03:00
Kirill Tkhai
20bc6aed12 crit: Use ns_pid, ns_sid and ns_gid
Reflect commit 3086b0323cf8 "pstree: Dump and restore NSpid, NSsid etc"
in crit.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:13 +03:00
Pavel Emelyanov
babc8b3d74 crit: Files now sit in another image
When merging files into one image we've forgotten about crit x
feature that scans image files by names.

https://github.com/xemul/criu/issues/381

The patch was made for master (as in criu-dev there was problem
with pstree_item.pid parsing), but should apply to dev smoothly.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-25 13:03:16 +03:00
Pavel Emelyanov
af6e70b2b9 crit: RSS explorer
When running 'cirt x dir rss' one will see the way pagemap chunks
are scatered across the VMs of processes. Sample output from the
env00 zdtm test is

22
	400000 / 1              00400000 / 5        /root/criu/test/zdtm/static/env00

	604000 / 2              00604000 / 1        /root/criu/test/zdtm/static/env00
	                        00605000 / 1        /root/criu/test/zdtm/static/env00

	853000 / 1              00853000 / 33

	7faba2d4b000 / 6        7faba2d4b000 / 4        /usr/lib64/libc-2.22.so
	                        7faba2d4f000 / 2        /usr/lib64/libc-2.22.so

	7faba2d51000 / 2        7faba2d51000 / 4

	7faba2d54000 / 1        ~

	7faba2f64000 / 3        7faba2f64000 / 3

	7faba2f74000 / 1        7faba2f74000 / 1

	7faba2f75000 / 2        7faba2f75000 / 1        /usr/lib64/ld-2.22.so
	                        7faba2f76000 / 1        /usr/lib64/ld-2.22.so

	7faba2f77000 / 1        7faba2f77000 / 1

	7fffb4de3000 / 3        7fffb4de2000 / 70

	7fffb4e24000 / 2        ~

	7fffb4e27000 / 1        ~

	7fffb4f6a000 / 2        7fffb4f6a000 / 2

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-05-19 09:14:45 +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 Tikhomirov
39cbd91672 crit/decode: set default opts['nopl'] to False
to fix error:

./crit/crit decode -i test/dump/zdtm/static/maps04/118/1/stats-dump
Traceback (most recent call last):
  File "./crit/crit", line 276, in <module>
    main()
  File "./crit/crit", line 273, in main
    opts["func"](opts)
  File "./crit/crit", line 28, in decode
    img = pycriu.images.load(inf(opts), opts['pretty'], opts['nopl'])
KeyError: 'nopl'

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-05-30 13:47:54 +03:00
Pavel Emelyanov
4ead159258 crit: Show no payload for image objects
In some images there can be quite a long "payload" -- some
raw data that is represented by base64 encoding. If we want
to explore huge images reading tons of base64 symbols can
be quite time consuming :) E.g. I a 1.5 gigs image with sysv
shmem was sent to me some time ago for investigation %)

So here is the --nopl argument for show action (decode should
produce encode-able image, so payload there is needed) that
just shows the amount of bytes in payload (if any).

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-05-30 13:47:54 +03:00
Cyrill Gorcunov
c1dabe8cfb crit: Add symbolic link for pycriu module
When we run "make install" the python's setup
script prepares all directories for modules
but if we need to run crit from the source
tree without its install then we fall in trouble
because python doesn't know where the fetch
pycriu from.

Thus simply provide the symlink to the modules
emulating that instalation complete.

Note this is for developers conveniency only
because for end users "make install" always
must has place.

Reported-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-01 12:50:47 +03:00
Cyrill Gorcunov
3410d39514 build: Move crit tool into crit directory
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-15 15:32:42 +03:00
Pavel Emelyanov
25a978d32e crit: The 'mems' explorer
This one prints the /proc/pid/maps-like output, but with slightly more
details. Like this

1
	exe                                     /zdtm/live/static/maps00
	00400000-00406000                   r-x /zdtm/live/static/maps00
	00605000-00606000                   r-- /zdtm/live/static/maps00 + 0x5000
	00606000-00607000                   rw- /zdtm/live/static/maps00 + 0x6000
	7f4037845000-7f40379f9000           r-x /lib64/libc.so.6
	7f40379f9000-7f4037bf8000           --- /lib64/libc.so.6 + 0x1b4000
	7f4037bf8000-7f4037bfc000           r-- /lib64/libc.so.6 + 0x1b3000
	7f4037bfc000-7f4037bfe000           rw- /lib64/libc.so.6 + 0x1b7000
	7f4037bfe000-7f4037c03000           rw-
	7f4037c03000-7f4037c23000           r-x /lib64/ld-linux-x86-64.so.2
	7f4037e1e000-7f4037e22000           rw-
	7f4037e22000-7f4037e23000           r-- /lib64/ld-linux-x86-64.so.2 + 0x1f000
	7f4037e23000-7f4037e24000           rw- /lib64/ld-linux-x86-64.so.2 + 0x20000
	7f4037e24000-7f4037e25000           rw-
	7fff34652000-7fff34699000           rw- [stack?]
	7fff346e2000-7fff346e4000           r--
	7fff346e4000-7fff346e6000           r-x [vdso]
	ffffffffff600000-ffffffffff601000   r-x [vsyscall] *

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:14:57 +03:00
Pavel Emelyanov
6c8f7bbb29 crit: The 'fds' explorer
Shows files opened by tasks. The output is like

1
	      0: /dev/null
	      1: /zdtm/live/static/session00.outns
	      2: /zdtm/live/static/session00.outns
	    cwd: /zdtm/live/static
	   root: /
6
	      0: /dev/null
	      1: /zdtm/live/static/session00.out.inprogress
	      2: /zdtm/live/static/session00.out.inprogress
	      3: pipe[18305]
	    cwd: /zdtm/live/static
	   root: /
10
	      0: /dev/null
	      1: /zdtm/live/static/session00.out.inprogress
	      2: /zdtm/live/static/session00.out.inprogress
	      3: pipe[18308]
	    cwd: /zdtm/live/static
	   root: /

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Appreciated-by: avagin@openvz.org
2015-12-16 18:14:56 +03:00
Pavel Emelyanov
022baf868b crit: The 'ps' explorer
Shows process tree from image. The output is like

    PID   PGID    SID   COMM
      1      1      1   session00
      4      4      4       session00
      7      7      7           session00
      8      4      4           session00
     11     11     11           session00
     12      4      4               session00
     13     13     13           session00
     14     14     14               session00
     15      4      4                   session00
      6      4      4       session00
     10      9      9       session00

(the above is for session00 test).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Appreciated-by: avagin@openvz.org
2015-12-16 18:14:55 +03:00
Pavel Emelyanov
075c1c9f08 crit: Explore action and stubs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Appreciated-by: avagin@openvz.org
2015-12-16 18:14:54 +03:00
Kir Kolyshkin
01a99c0a63 crit: fix decode usage help
Was:
    decode              convert criu image from binary type json

Now:
    decode              convert criu image from binary type to json

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-05 15:24:04 +03:00
Pavel Emelyanov
d2f8f481c7 crit: Introduce 'info' action
This should print some information about image file itself, e.g.
statistical information. Right now print magic and the number of
object written in the file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:51:39 +03:00
Tycho Andersen
1de38f344d crit: add a show option for human consumption
This saves some keystrokes and is equivalent to decode --pretty.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-23 15:15:27 +03:00
Pavel Emelyanov
dbda403b8d crit: Avoid full exception trace when meeting unknown magic in image (v2)
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2015-05-30 00:32:27 +03:00
Ruslan Kuprieiev
0b08bcfcad crit: gather and parse arguments in a proper way
This will allow us to easily extend commands that crit
supports, avoiding "--help" confusion.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-09 14:08:22 +03:00
Pavel Emelyanov
0d2aeb3581 crit: Get rid of --format option
I plan to mark some fields as IP address and print them respectively.
The --format hex is not nice switch for this and introducing one more
(--format hex ipadd) is too bad.

So let's fix the cirt API to be simple and stupid. By default crit
generates canonical one-line JSON. With --pretty option it splits the
output into lines, adds indentation and prints hex as hex and IP as
IP.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Ruslan Kuprieiev <kupruser@gmail.com>
2015-01-29 18:47:13 +03:00
Ruslan Kuprieiev
87da3e3437 crit: add --format hex option
Pavel reported that decimal values for some fields are hard to read,
because people used to see hex values in there. Unfortunately, json
doesn't support hex representation of integers, so we can only store
them as hex strings. Not all field need to be represented as hex
strings, so this set introduces a custom field option called "criu"
to use in our proto files. One should use [(criu).hex = true] to mark
which field should be represented as a hex string. pb2dict module
from pycriu package will look into field options and if he finds that
criu.hex is set to True, it will convert such field to/from hex string.
Though, such behaviour is optional and user can request it by specifying
 --format hex when calling crit decode("crit encode" in its turn, detects
such fields automatically and doesn't require any special cmdline options
to be set).

We need our proto files to compile with both protoc and
protoc-c compilers, which requires creating google/protobuf
directory with a symlink to /usr/include/google/protobuf/
descriptor.proto to make protoc-c and generated c files happy.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-19 18:13:55 +04: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
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
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
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