[CRIU] [PATCH] crit: Use ns_pid, ns_sid and ns_gid

Andrei Vagin avagin at virtuozzo.com
Mon Sep 4 23:42:09 MSK 2017


On Mon, Sep 04, 2017 at 11:02:16AM +0300, Kirill Tkhai wrote:
> Reflect commit 3086b0323cf8 "pstree: Dump and restore NSpid, NSsid etc"
> in crit.
> 
> https://github.com/xemul/criu/issues/382
> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  crit/crit |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/crit/crit b/crit/crit
> index a6a6832b5..d7b6f03c7 100755
> --- a/crit/crit
> +++ b/crit/crit
> @@ -55,14 +55,14 @@ import pycriu
>  
>  class ps_item:
>  	def __init__(self, p, core):
> -		self.pid = p['pid']
> +		self.pid = p['ns_pid'][0]

How will it work with old images after this changes?

>  		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, p.p['ns_pgid'][0], p.p['ns_sid'][0],
>  			' ' * (4 * depth), p.core['tc']['comm'])
>  	for kid in p.kids:
>  		show_ps(kid, opts, depth + 1)
> @@ -71,7 +71,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' % p['ns_pid'][0]))
>  		ps = ps_item(p, core['entries'][0])
>  		pss[ps.pid] = ps
>  
> @@ -138,7 +138,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 = p['ns_pid'][0]
>  		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 +170,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 = p['ns_pid'][0]
>  		mmi = pycriu.images.load(dinf(opts, 'mm-%d.img' % pid))['entries'][0]
>  
>  		print "%d" % pid
> @@ -215,7 +215,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 = p['ns_pid'][0]
>  		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