[CRIU] [PATCH 10/10] parasite: Switch parasite to daemon mode

Cyrill Gorcunov gorcunov at openvz.org
Mon Mar 4 07:53:18 EST 2013


Parasite daemon mode it quite tricky. One may consider
it as consisting of two parts

 - daemon mode for thread leader
 - daemon mode for regular threads

Thread leader daemon
--------------------

Once thread leader parasite code switched initialized,
it starts spinning on socket listening for commands
to handle.

If the command destination is the thread leader itself it
handles it and replies back the ack to the caller (iow
the main crtools code).

If the recepient is not thread leader but one of threads,
then thread leader wakes up the thread by futex and makes
it to handle the command waiting on futex for result. Once
result obtained, the ack is being sending back to caller.

Thread daemon
-------------

On initialization thread daemon starts waiting a command on futex.
The futex is triggered by thread leader daemon when command received.
Once command is received and handled, the result is reported back to
the thread leader daemon, which in turn send ack message.

Both thread-leader and regular threads require own stack to operate
on since they all are present in memory simultaneously. Thus we use
call_daemon_thread() helper which takes care of providing stack
to the callee.

TODO:

 - ARM requires own wrappers on damonize/trap low-level code,
   at moment x86-64 is only covered

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 parasite-syscall.c | 215 +++++++++++++++++++++++++++++++++++++++-----
 pie/parasite.c     | 256 ++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 407 insertions(+), 64 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0010-parasite-Switch-parasite-to-daemon-mode.patch
Type: text/x-patch
Size: 18481 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/criu/attachments/20130304/67172894/attachment-0001.bin>


More information about the CRIU mailing list