[CRIU] [PATCH v2] crit: Use ns_pid, ns_sid and ns_gid
Kirill Tkhai
ktkhai at virtuozzo.com
Tue Sep 5 11:19:41 MSK 2017
Reflect commit 3086b0323cf8 "pstree: Dump and restore NSpid, NSsid etc"
in crit.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
v2: Support old dumps without ns_pid too.
crit/crit | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/crit/crit b/crit/crit
index a6a6832b5..7099ec81e 100755
--- a/crit/crit
+++ b/crit/crit
@@ -49,20 +49,22 @@ import pycriu
json.dump(infs, sys.stdout, indent = 4)
print
+def get_task_id(p, val):
+ return p[val] if val in p else p['ns_' + val][0]
#
# Explorers
#
class ps_item:
def __init__(self, p, core):
- self.pid = p['pid']
+ self.pid = get_task_id(p, 'pid')
self.ppid = p['ppid']
self.p = p
self.core = core
self.kids = []
def show_ps(p, opts, depth = 0):
- print "%7d%7d%7d %s%s" % (p.pid, p.p['pgid'], p.p['sid'],
+ print "%7d%7d%7d %s%s" % (p.pid, get_task_id(p.p, 'pgid'), get_task_id(p.p, 'sid'),
' ' * (4 * depth), p.core['tc']['comm'])
for kid in p.kids:
show_ps(kid, opts, depth + 1)
@@ -71,7 +73,7 @@ import pycriu
pss = { }
ps_img = pycriu.images.load(dinf(opts, 'pstree.img'))
for p in ps_img['entries']:
- core = pycriu.images.load(dinf(opts, 'core-%d.img' % p['pid']))
+ core = pycriu.images.load(dinf(opts, 'core-%d.img' % get_task_id(p, 'pid')))
ps = ps_item(p, core['entries'][0])
pss[ps.pid] = ps
@@ -138,7 +140,7 @@ files_cache = { }
def explore_fds(opts):
ps_img = pycriu.images.load(dinf(opts, 'pstree.img'))
for p in ps_img['entries']:
- pid = p['pid']
+ pid = get_task_id(p, 'pid')
idi = pycriu.images.load(dinf(opts, 'ids-%s.img' % pid))
fdt = idi['entries'][0]['files_id']
fdi = pycriu.images.load(dinf(opts, 'fdinfo-%d.img' % fdt))
@@ -170,7 +172,7 @@ files_cache = { }
ps_img = pycriu.images.load(dinf(opts, 'pstree.img'))
vids = vma_id()
for p in ps_img['entries']:
- pid = p['pid']
+ pid = get_task_id(p, 'pid')
mmi = pycriu.images.load(dinf(opts, 'mm-%d.img' % pid))['entries'][0]
print "%d" % pid
@@ -215,7 +217,7 @@ files_cache = { }
def explore_rss(opts):
ps_img = pycriu.images.load(dinf(opts, 'pstree.img'))
for p in ps_img['entries']:
- pid = p['pid']
+ pid = get_task_id(p, 'pid')
vmas = pycriu.images.load(dinf(opts, 'mm-%d.img' % pid))['entries'][0]['vmas']
pms = pycriu.images.load(dinf(opts, 'pagemap-%d.img' % pid))['entries']
More information about the CRIU
mailing list