This makes tests that finish some time run smoother -- no tons of Waiting... messages
on the screen
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Make it in two stages.
First -- collect pipe data into hash without checking for pipe/fifo existance.
Next -- when pipe/fifo gets restored walk the hash and search where the pipe data
is.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The existing code checks for ID to be already dumped. But pipe and fifo may have the same ID
since they reside on different filesystems.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This routine checks for pipe data being dumped based on pipe ID, but the arg in questoin
is the pipe's end ID which makes code reading confusing.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The ret var is set to -1 at the beginning and the very first loop
will break and report it to the caller thus stopping the restore :(
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We will need to use pointer here (to PB object) anyway
so better to make it in a separate patch for bisectability sake.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Address Andrew's comments
- use TEST_VALUE macro instead of open coded value
- use WIFx macros for child status testing
- kill child/parent on error
Note that it was not clear from an initiall patch
change log -- the difference between fifo_wronly
test case and this one is that we use fork() call
here which allow us to make sure that fifo restoration
code logic will be tested more widely.
Basically the flowchart of the test case:
parent child
------ -----
open RW fifo (slave)
open RO fifo (master)
open WO fifo (master)
dup parent slave to slave1
... waiting c/r to happen ...
... waking up from c/r ...
send bytes to master
send bytes to slave1
finish
... initiating c/r ...
... waking up from c/r ...
read bytes from master
read bytes from slave
PASS :D
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Just like for orphaned sessions, create a fake task for orphaned pgids.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
As described in the previous patch, process group leaders are restored in
the first phase, then all other processes restores pgid.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Pgid leader should become such before any other task tries
to enter this group (with setpgid). Thus we introduce a yet
another global sync point -- before it all pgid leaders call
setpgid after it all the others do it.
v2: wait while helpers restored pgid
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
A process tree is described in the array. New cases are easy for adding.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We can't reuse it from crtools, because zdtm is used separately.
v2 syscall() returns an error code in errno.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Don't push open cb onto reg_file_into, pass it into regfiles engine
as an argument.
Note: I haven't merged the fifo zdtms yet, thus this patch is untested.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Tested-by: Cyrill Gorcunov <gorcunov@openvz.org>
I need a special test case where fake
fifo will be created by us to restore
the former.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Checkpoint and restore of fifo is similar to
pipes c/r except the pipe end-points are named
file.
Because the fifo has a name we use regular files
facility for fifo path c/r.
Still there is a trick used to "open" fifo:
the opening procedure migh sleep if a fifo's peer
is not yet opened, so before doing a real open
we yield a fake open procedure (with O_RDWR flag)
which prevents us from sleeping even if peer
is not yet ready. Also we need writable fifo
end to restore data queued.
v2:
- add open/priv members to reg_file_info
- make open_fifo_fd to use open_fe_fd
- comment on pipe_id
- make sure the fifo data is not restored twice
v3:
- drop useless fixme comment and add sane one
v4:
- Use restore_data flag to escape data restore duplication
- Use S_ISREG for file contents copying
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Allow file path remap engine to create fifo nodes.
Note for fifos the copy_file is not called since
we will restore fifo data via pipe-data engine.
v2
- no need for dev in mknod
- don't reopen local copy on fifo files
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
To reuse with fifo data restore.
v2:
- use image type in functions arguments instead of forcing
calling side to provide file descriptor
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v2:
- Use do_dump_opt in dump_socket to not call
lookup_socket redundantly
v3:
- use getsockopt to check that unconnected
socket has no peername and it's not listening
- do test only socket protocol since family and
type will be called in dump_one_inet_fd.
v4:
- Move proto tests to can_dump_inet_sk
- Use SOL_TCP/TCP_INFO to gather info about tcp sockets
v5:
- hash unconnected sockets to run BUG_ON(already-dumped) logic
- no default value for sk->wqlen, use zero from xzalloc
- drop bogus xfree on error
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It may occur that the loop spins faster than clock ticks.
Signed-off-by: Evgeny Antyshev <eantyshev@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
expr prints a substing length. This patch redirects output of expr to /dev/null
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It requered 1m19s for executing all tests.
Now it requires 38s.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Sometime we need sync points in testee program flow,
for this reason task_waiter_ introduced.
The call semantics is the following
Parent Child
------ -----
task_waiter_init
task_waiter_wait4
task_waiter_complete
task_waiter_wait4
task_waiter_complete
...
Thus initially task_waiter_init should be called
to initialize all internals guts needed.
Then one become waitee and calls for task_waiter_wait4,
where lockid should be provided as an argument. Since
it should be unique values the best option might be
gettid().
The same applies to a waiter side -- it should call
for task_waiter_complete and provide a lockid.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Strictly speaking we have to close all fds before reopening them from the
image. This can be done using not yet merged nextfd syscall, but it's not
yet merged :( By now just close std and 255 (bash's) descriptors. This is
ugly, but I prefer to wait for the nextfd syscall.
But skip the init tasks' stds becase the existing zdtm implementation
uses system() in such tasks which doesn't work when all fds are closed.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Test with sysfs and proc as no other fs-s are currently supported.
Will be fixed later.
Note, that the original /proc mount is kept as the dumping code requires
it for reading pagemap file with RSS info. Worth fixing it some day?
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We need own proc for restoring mount namespace, since the proc should
be umounted and mounted back diring namespace restore and I don't want
to introduce a special kludge for this.
One more notice -- the temp proc is mounted _after_ namespaces recreation
for the same reason (it will be umounted by prepare_mnt_ns).
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Only support virtual filesystems mount. No bindmounts or disk fs
due to non trivial resolving of devices names and binmount sources.
Will be implemented later.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Two walkers -- in forward and reverse directions -- are required
for correct (u)mounting of subtrees. Implement them using a helper
macro which walks the tree in both directions.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Namespace restore goes in two steps -- first, clean old mountpoints
(except root) that are left after clone(CLONE_NEWNS) call. Next,
repopulate the namespace with new mountpoints (except root) read
from the image file.
This patch adds the skeleton for the above -- reading the mountpoints
from current proc and image and calling for mount/umount. The real
action will come in further patches.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>