[CRIU] [RFC v2 3/5] zdtm: add reset_pid() function

Adrian Reber adrian at lisas.de
Tue Apr 4 02:23:20 PDT 2017


On Thu, Mar 23, 2017 at 05:10:12PM -0700, Andrei Vagin wrote:
> On Thu, Mar 23, 2017 at 07:59:16PM +0000, Adrian Reber wrote:
> > From: Adrian Reber <areber at redhat.com>
> > 
> > In preparation for the zdtm option '--check-only' a new helper function
> > reset_pid() is added which writes to ns_last_pid to avoid PID collisions
> > during check-only restore and the real restore.
> > 
> > Signed-off-by: Adrian Reber <areber at redhat.com>
> > ---
> >  test/zdtm.py | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/test/zdtm.py b/test/zdtm.py
> > index 57e2ab0..8d38e05 100755
> > --- a/test/zdtm.py
> > +++ b/test/zdtm.py
> > @@ -329,6 +329,13 @@ def wait_pid_die(pid, who, tmo = 30):
> >  def test_flag(tdesc, flag):
> >  	return flag in tdesc.get('flags', '').split()
> >  
> > +
> > +def reset_pid(pid = 1):
> 
> I don't understand how pid = 1 helps to avoid collisions. We create a
> new pid namespace for each test (test/zdtm_ct) and we know that pids are
> allocated sequentialy, so test process uses
> "small" pids. In this case setting 1 into ns_last_pid has to increate
> probability of collisions...

The following tests fail in --check-only mode if I do not reset the PID
back to 1:

 * zdtm/static/zombie00(h)
 * zdtm/static/sched_prio00(h)
 * zdtm/static/pthread00(h)
 * zdtm/static/sigpending(h)
 * zdtm/static/fdt_shared(h)
 * zdtm/transition/epoll(h)
 * zdtm/transition/fork(h)
 * zdtm/transition/fork2(h)
 * zdtm/transition/maps008(h)
 * zdtm/transition/pipe_loop00(h)
 * zdtm/transition/socket_loop00(h)
 * zdtm/transition/unix_sock(h)
 * zdtm/transition/fifo_loop(h)
 * zdtm/transition/pipe_shared00(h)
 * zdtm/transition/file_read(h)

The test restore and the real restore are running in the same PID
namespace. For those testcases the real restore fails with a PID
collision:

(00.004419) Error (criu/cr-restore.c:1353): Pid 25 do not match expected 24

Resetting it to '1' helps.

		Adrian


More information about the CRIU mailing list