crit: Use ns_pid, ns_sid and ns_gid

Submitted by Kirill Tkhai on Sept. 4, 2017, 8:02 a.m.

Details

Message ID 150451210976.2648.3863221016760791797.stgit@localhost.localdomain
State New
Series "crit: Use ns_pid, ns_sid and ns_gid"
Headers show

Commit Message

Kirill Tkhai Sept. 4, 2017, 8:02 a.m.
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@virtuozzo.com>
---
 crit/crit |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

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]
 		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']
 

Comments

Cyrill Gorcunov Sept. 4, 2017, 8:10 a.m.
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@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Andrei Vagin Sept. 4, 2017, 8:42 p.m.
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@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']
>  
>
Kirill Tkhai Sept. 5, 2017, 6:45 a.m.
On 04.09.2017 23:42, Andrei Vagin wrote:
> 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@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?

It won't work, it will behave in style of kernel's perf: crit version corresponds to criu version.
 
>>  		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']
>>  
>>