Difference between revisions of "CRIT"

From CRIU
Jump to navigation Jump to search
(add a bit more verbose CRIT description and its purpose)
(Fix --pretty option)
Line 16: Line 16:
 
   -i IN, --in IN        input file (stdin by default)
 
   -i IN, --in IN        input file (stdin by default)
 
   -o OUT, --out OUT    output file (stdout by default)
 
   -o OUT, --out OUT    output file (stdout by default)
   -f {raw,nice}, --format {raw,nice}
+
   --pretty              multi-line with indentation and some fields printed in more human-readable format
                        well-formated output (by default: raw for files and
 
                        nice for stdout)
 
 
</pre>
 
</pre>
  

Revision as of 14:32, 3 February 2015

This page describes the CRiu Image Tool. CRIT is a feature-rich replacement for existing "criu show". It is written completely in Python, so it is quite easy to read the code and extend its features.

Usage

usage: crit [-h] [-i IN] [-o OUT] [-f {raw,nice}] {decode,encode}

CRiu Image Tool

positional arguments:
  {decode,encode}       decode/encode - convert criu image from/to binary type
                        to/from json

optional arguments:
  -h, --help            show this help message and exit
  -i IN, --in IN        input file (stdin by default)
  -o OUT, --out OUT     output file (stdout by default)
  --pretty              multi-line with indentation and some fields printed in more human-readable format

Functionality

Convert images to JSON and back

Status: ready

This is the replacement for (rather nasty) criu show code. Also this is the way to edit the images before restoring from them.

It uses text_format as a human-readable format for protobuf messages.

The output file is structured in the following way.

With "--format raw":

{ "magic" : "FOO", "entries" : [{"foo": "bar", "bar": "foo", "extra": "abc"}, {"foo": "bar", "bar" : "foo", "extra" : "abc"} ]}

With "--format nice"(default for stdout):

{
    "magic" : "FOO",
    "entries" : [
        {
            "foo" : "bar",
            "bar" : "foo",
            "extra" : "abc"
        },
        {
            "foo" : "bar",
            "bar" : "foo",
            "extra" : "abc"
        }
    ]
}

Example("crit decode -i core-20700.img")

{
    "magic": "CORE", 
    "entries": [
        {
            "mtype": "X86_64", 
            "thread_core": {
                "futex_rla_len": 24, 
                "sched_policy": 0, 
                "sched_nice": 0, 
                "futex_rla": 0, 
                "signals_p": {}, 
                "sas": {
                    "ss_size": 0, 
                    "ss_sp": 0, 
                    "ss_flags": 2
                }
            }, 
            "thread_info": {
                "fpregs": {
                    "st_space": [
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0
                    ], 
                    "fop": 0, 
                    "rdp": 0, 
                    "twd": 0, 
                    "mxcsr": 8064, 
                    "swd": 0, 
                    "rip": 0, 
                    "xsave": {
                        "ymmh_space": [
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0, 
                            0
                        ], 
                        "xstate_bv": 2
                    }, 
                    "xmm_space": [
                        1953064751, 
                        1769104175, 
                        1702113141, 
                        1664054387, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        4294901760, 
                        255, 
                        0, 
                        792358505, 
                        1953460082, 
                        1852400175, 
                        0, 
                        942882145, 
                        876295483, 
                        774519349, 
                        1031303283, 
                        893073459, 
                        976565307, 
                        1937255978, 
                        859661936, 
                        993344312, 
                        3814708, 
                        65, 
                        0, 
                        21771440, 
                        0, 
                        21771552, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        4278190080, 
                        4294967295, 
                        4294967040, 
                        4294967295, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        4278190080, 
                        4294967040, 
                        4294967295, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0, 
                        0
                    ], 
                    "cwd": 0, 
                    "mxcsr_mask": 65535
                }, 
                "clear_tid_addr": 0, 
                "gpregs": {
                    "gs": 0, 
                    "ip": 140137968588056, 
                    "cx": 18446744073709551615, 
                    "cs": 51, 
                    "ax": 61, 
                    "orig_ax": 61, 
                    "di": 18446744073709551615, 
                    "es": 0, 
                    "gs_base": 0, 
                    "r14": 0, 
                    "r15": 4294967295, 
                    "r12": 21789168, 
                    "r13": 0, 
                    "r10": 0, 
                    "r11": 582, 
                    "fs_base": 140137978173184, 
                    "bp": 2560, 
                    "dx": 0, 
                    "bx": 0, 
                    "ds": 0, 
                    "ss": 43, 
                    "sp": 140736135950616, 
                    "r8": 21789168, 
                    "r9": 0, 
                    "fs": 0, 
                    "si": 140736135950656, 
                    "flags": 582
                }
            }, 
            "tc": {
                "timers": {
                    "real": {
                        "isec": 0, 
                        "vusec": 0, 
                        "iusec": 0, 
                        "vsec": 0
                    }, 
                    "virt": {
                        "isec": 0, 
                        "vusec": 0, 
                        "iusec": 0, 
                        "vsec": 0
                    }, 
                    "prof": {
                        "isec": 0, 
                        "vusec": 0, 
                        "iusec": 0, 
                        "vsec": 0
                    }
                }, 
                "cg_set": 1, 
                "signals_s": {}, 
                "blk_sigset": 65536, 
                "exit_code": 0, 
                "rlimits": {
                    "rlimits": [
                        {
                            "max": 18446744073709551615, 
                            "cur": 18446744073709551615
                        }, 
                        {
                            "max": 18446744073709551615, 
                            "cur": 18446744073709551615
                        }, 
                        {
                            "max": 18446744073709551615, 
                            "cur": 18446744073709551615
                        }, 
                        {
                            "max": 18446744073709551615, 
                            "cur": 8388608
                        }, 
                        {
                            "max": 18446744073709551615, 
                            "cur": 0
                        }, 
                        {
                            "max": 18446744073709551615, 
                            "cur": 18446744073709551615
                        }, 
                        {
                            "max": 62845, 
                            "cur": 62845
                        }, 
                        {
                            "max": 4096, 
                            "cur": 1024
                        }, 
                        {
                            "max": 65536, 
                            "cur": 65536
                        }, 
                        {
                            "max": 18446744073709551615, 
                            "cur": 18446744073709551615
                        }, 
                        {
                            "max": 18446744073709551615, 
                            "cur": 18446744073709551615
                        }, 
                        {
                            "max": 62845, 
                            "cur": 62845
                        }, 
                        {
                            "max": 819200, 
                            "cur": 819200
                        }, 
                        {
                            "max": 0, 
                            "cur": 0
                        }, 
                        {
                            "max": 0, 
                            "cur": 0
                        }, 
                        {
                            "max": 18446744073709551615, 
                            "cur": 18446744073709551615
                        }
                    ]
                }, 
                "comm": "loop.sh", 
                "flags": 1077960704, 
                "task_state": 1, 
                "personality": 0
            }
        }
    ]
}

Generate core files out of task images

Status: not ready

All the needed information is in core-$pid.img and pagemap-$pid.img

On-the-fly conversion

Status: not ready

There's an idea to make CRIU spawn CRIT and read images "through" it, to allow for at-the-restore-time modifications

Convert between different image versions

Status: not ready

Right now we store the images version in inventory.img and collect info about what's bad with V1 images. If some day we have v2, CRIT will convert from v1. And for backward compatibility we'll use on-the-fly conversion when restoring from old images.

Show images statistics

Status: not ready

E.g. -- total number of processes, files, memory, sockets, etc.

Check/validate images

Status: not ready

Check that

  • all images are present
  • the inter-images IDs are in consistent state