Changes

Jump to navigation Jump to search
15,484 bytes added ,  10:17, 27 March 2019
Line 1: Line 1: −
This page describes the CRiu Image Tool.
+
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 ==
 +
<pre>
 +
usage: crit [-h] {decode,encode,info,x,show} ...
 +
 
 +
CRiu Image Tool
 +
 
 +
positional arguments:
 +
  {decode,encode,info,x,show}
 +
                        Use crit CMD --help for command-specific help
 +
    decode              convert criu image from binary type to json
 +
    encode              convert criu image from json type to binary
 +
    info                show info about image
 +
    x                  explore image dir
 +
    show                convert criu image from binary to human-readable json
 +
 
 +
optional arguments:
 +
  -h, --help            show this help message and exit
 +
</pre>
 +
 
 +
=== Pretty output ===
 +
 
 +
Command <decode> prints JSON text in one line. This can be read by any further JSON-aware tool for parsing. For human eyes it's more convenient to read JSON multi-line with indentation. CRIT can do this when using the <code>show</code> action or the <code>--pretty</code> option.
 +
 
 +
Wend doing pretty optput CRIT does a little bit more, than just multiline indented JSON.
 +
 
 +
; Addresses and registers
 +
: VM addresses and core.img register values are all printed in hex. Since JSON doesn't support this form of numbers, such fields are encoded as strings.
 +
 
 +
; Bit-fields
 +
: Such things as flags and masks (e.g. sig-block mask) are also better understood when written in hex, so CRIT does this.
 +
 
 +
; IP addresses
 +
: By default those a printed in decimal, but the "1.2.3.4" for v4 or "::1" for v6 can be seen in the --pretty mode.
 +
 
 +
; Symbolic names for flags
 +
: Some known bit sets (e.g. MAP_PRIVATE, MAP_ANONYMOUS, etc. for vma->flags) are shown with names.
 +
 
 +
; Device numbers
 +
: If the field is known to be of <code>dev_t</code> type, it's printed in the <code>major:minor</code> manner
    
== Functionality ==
 
== Functionality ==
   −
=== Convert images to human-readable and back ===
+
=== Convert images to JSON and back ===
 +
 
 +
 
 +
This is the replacement for (rather nasty) <code>criu show</code> code. Also this is the way to edit the images before restoring from them.
 +
 
 +
It uses [https://developers.google.com/protocol-buffers/docs/reference/python/google.protobuf.text_format-module text_format] as a human-readable format for protobuf messages.
 +
 
 +
The output file is structured in the following way.
   −
This is the replacement for (rather nasty) criu show code. Also this is the way to edit the images before restoring from them.
+
Without "--pretty":
 +
<pre>
 +
{ "magic" : "FOO", "entries" : [{"foo": "bar", "bar": "foo", "extra": "abc"}, {"foo": "bar", "bar" : "foo", "extra" : "abc"} ]}
 +
</pre>
   −
=== Convert to json (and back) ===
+
With "--pretty":
 +
<pre>
 +
{
 +
    "magic" : "FOO",
 +
    "entries" : [
 +
        {
 +
            "foo" : "bar",
 +
            "bar" : "foo",
 +
            "extra" : "abc"
 +
        },
 +
        {
 +
            "foo" : "bar",
 +
            "bar" : "foo",
 +
            "extra" : "abc"
 +
        }
 +
    ]
 +
}
 +
</pre>
   −
Same as before, but the human-readable format is JSON
+
<div class="toccolours mw-collapsible mw-collapsed" style="width:800px">
 +
<b>Example("crit decode -i core-5679.img --pretty")</b>
 +
<div class="mw-collapsible-content">
 +
<pre>
 +
{
 +
    &quot;magic&quot;: &quot;CORE&quot;,
 +
    &quot;entries&quot;: [
 +
        {
 +
            &quot;mtype&quot;: &quot;X86_64&quot;,
 +
            &quot;thread_core&quot;: {
 +
                &quot;futex_rla_len&quot;: 24,
 +
                &quot;sched_policy&quot;: 0,
 +
                &quot;sched_nice&quot;: 0,
 +
                &quot;futex_rla&quot;: 0,
 +
                &quot;signals_p&quot;: {},
 +
                &quot;sas&quot;: {
 +
                    &quot;ss_size&quot;: 0,
 +
                    &quot;ss_sp&quot;: 0,
 +
                    &quot;ss_flags&quot;: 2
 +
                }
 +
            },
 +
            &quot;thread_info&quot;: {
 +
                &quot;fpregs&quot;: {
 +
                    &quot;st_space&quot;: [
 +
                        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
 +
                    ],
 +
                    &quot;fop&quot;: 0,
 +
                    &quot;rdp&quot;: 0,
 +
                    &quot;twd&quot;: 0,
 +
                    &quot;mxcsr&quot;: 8064,
 +
                    &quot;swd&quot;: 0,
 +
                    &quot;rip&quot;: 0,
 +
                    &quot;xsave&quot;: {
 +
                        &quot;ymmh_space&quot;: [
 +
                            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
 +
                        ],
 +
                        &quot;xstate_bv&quot;: 2
 +
                    },
 +
                    &quot;xmm_space&quot;: [
 +
                        0,
 +
                        4278190080,
 +
                        4294967295,
 +
                        4294967295,
 +
                        1701145715,
 +
                        3219568,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        33,
 +
                        0,
 +
                        792358505,
 +
                        1953460082,
 +
                        1852400175,
 +
                        0,
 +
                        942882145,
 +
                        876295483,
 +
                        774519349,
 +
                        1031303283,
 +
                        893073459,
 +
                        976565307,
 +
                        1937255978,
 +
                        859661936,
 +
                        993344312,
 +
                        3814708,
 +
                        65,
 +
                        0,
 +
                        37049520,
 +
                        0,
 +
                        37049632,  
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        4294901760,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0,
 +
                        0
 +
                    ],
 +
                    &quot;cwd&quot;: 0,
 +
                    &quot;mxcsr_mask&quot;: 65535
 +
                },
 +
                &quot;clear_tid_addr&quot;: 0,
 +
                &quot;gpregs&quot;: {
 +
                    &quot;gs&quot;: &quot;0x0&quot;,
 +
                    &quot;ip&quot;: &quot;0x7f172cf1ea04&quot;,
 +
                    &quot;cx&quot;: &quot;0xffffffffffffffff&quot;,
 +
                    &quot;cs&quot;: &quot;0x33&quot;,
 +
                    &quot;ax&quot;: &quot;0x38&quot;,
 +
                    &quot;orig_ax&quot;: &quot;0x38&quot;,
 +
                    &quot;di&quot;: &quot;0x1200011&quot;,
 +
                    &quot;es&quot;: &quot;0x0&quot;,
 +
                    &quot;gs_base&quot;: &quot;0x0&quot;,
 +
                    &quot;r14&quot;: &quot;0x0&quot;,
 +
                    &quot;r15&quot;: &quot;0x2355e00&quot;,
 +
                    &quot;r12&quot;: &quot;0x7ffffdbf74f0&quot;,
 +
                    &quot;r13&quot;: &quot;0x0&quot;,
 +
                    &quot;r10&quot;: &quot;0x7f172d83d9d0&quot;,
 +
                    &quot;r11&quot;: &quot;0x246&quot;,
 +
                    &quot;fs_base&quot;: &quot;0x7f172d83d700&quot;,
 +
                    &quot;bp&quot;: &quot;0x7ffffdbf7530&quot;,
 +
                    &quot;dx&quot;: &quot;0x0&quot;,
 +
                    &quot;bx&quot;: &quot;0x0&quot;,
 +
                    &quot;ds&quot;: &quot;0x0&quot;,
 +
                    &quot;ss&quot;: &quot;0x2b&quot;,
 +
                    &quot;sp&quot;: &quot;0x7ffffdbf74f0&quot;,
 +
                    &quot;r8&quot;: &quot;0x0&quot;,
 +
                    &quot;r9&quot;: &quot;0x0&quot;,
 +
                    &quot;fs&quot;: &quot;0x0&quot;,
 +
                    &quot;si&quot;: &quot;0x0&quot;,
 +
                    &quot;flags&quot;: &quot;0x246&quot;
 +
                }
 +
            },
 +
            &quot;tc&quot;: {
 +
                &quot;timers&quot;: {
 +
                    &quot;real&quot;: {
 +
                        &quot;isec&quot;: 0,
 +
                        &quot;vusec&quot;: 0,
 +
                        &quot;iusec&quot;: 0,
 +
                        &quot;vsec&quot;: 0
 +
                    },
 +
                    &quot;virt&quot;: {
 +
                        &quot;isec&quot;: 0,
 +
                        &quot;vusec&quot;: 0,
 +
                        &quot;iusec&quot;: 0,
 +
                        &quot;vsec&quot;: 0
 +
                    },
 +
                    &quot;prof&quot;: {
 +
                        &quot;isec&quot;: 0,
 +
                        &quot;vusec&quot;: 0,
 +
                        &quot;iusec&quot;: 0,
 +
                        &quot;vsec&quot;: 0
 +
                    }
 +
                },
 +
                &quot;cg_set&quot;: 1,
 +
                &quot;signals_s&quot;: {},
 +
                &quot;blk_sigset&quot;: &quot;0x10002&quot;,
 +
                &quot;exit_code&quot;: 0,
 +
                &quot;rlimits&quot;: {
 +
                    &quot;rlimits&quot;: [
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 18446744073709551615
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 18446744073709551615
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 18446744073709551615
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 8388608
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 0
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 18446744073709551615
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 62844,
 +
                            &quot;cur&quot;: 62844
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 4096,
 +
                            &quot;cur&quot;: 1024
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 65536,
 +
                            &quot;cur&quot;: 65536
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 18446744073709551615
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 18446744073709551615
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 62844,
 +
                            &quot;cur&quot;: 62844
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 819200,
 +
                            &quot;cur&quot;: 819200
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 0,
 +
                            &quot;cur&quot;: 0
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 0,
 +
                            &quot;cur&quot;: 0
 +
                        },
 +
                        {
 +
                            &quot;max&quot;: 18446744073709551615,
 +
                            &quot;cur&quot;: 18446744073709551615
 +
                        }
 +
                    ]
 +
                },
 +
                &quot;comm&quot;: &quot;loop.sh&quot;,
 +
                &quot;flags&quot;: 1077960704,
 +
                &quot;task_state&quot;: 1,
 +
                &quot;personality&quot;: 0
 +
            }
 +
        }
 +
    ]
 +
}
 +
</pre>
 +
</div>
 +
</div>
    
=== Generate core files out of task images ===
 
=== Generate core files out of task images ===
   −
All the needed information is in core-$pid.img and pagemap-$pid.img
+
Moved into separate project called [[criu-coredump]].
 +
 
 +
=== Show images statistics ===
 +
 
 +
E.g. -- total number of processes, files, memory, sockets, etc.
 +
Use
 +
<pre>
 +
crit x $directory_with_images <explore type>
 +
</pre>
 +
 
 +
Supported explorers are
 +
;'ps'
 +
:to show process tree
 +
 
 +
;'fds'
 +
:to show files used by tasks
 +
 
 +
;'mems'
 +
:to show memory mappings info
 +
 
 +
== Planned functionality ==
    
=== On-the-fly conversion ===
 
=== On-the-fly conversion ===
   −
There's an idea to make CRIU spawn CRIT and read images "through" it, to allow for at-the-restore-time modifications
+
There's an idea to make CRIU spawn CRIT and read images "through" it, to allow for at-the-restore-time modifications. For details, see https://github.com/xemul/criu/issues/59.
    
=== Convert between different image versions ===
 
=== Convert between different image versions ===
    
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.
 
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.
 +
 +
=== Check/validate images ===
 +
 +
Check that
 +
* all images are present
 +
* the inter-images IDs are in consistent state
 +
 +
For details, see https://github.com/xemul/criu/issues/44.
 +
 +
=== [[Anonymize image files]] ===
 +
 +
Since images contain raw memory dumps people may refuse to send us images for debugging. Need to anonymize them, i.e. -- remove this sensitive information.
 +
 +
[[Category:Images]]
 +
[[Category:API]]

Navigation menu