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

Cyrill Gorcunov gorcunov at openvz.org
Thu Feb 28 10:35:57 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
--------------------

On initialization we pass a control socket to parasite
thread leader daemon code via old ptrace interface.

Once socket is created, the thread leader parasite
code switched to daemon mode and start listening for
commands received on control socket.

Every command consists of 4 fields

 - @id -- command recipient (basically it's global pid seen in main crtools module)
 - @cmd -- command to handle
 - @ack -- to reply once handled
 - @err -- error code to return after handling the command

The thread leader daemon grabs command and if @id belongs to one
of the regular thread -- the command passed to thread daemon to
handle. Once the command is handled, thread leader daemon replies
upward to crtools module the result, via control socket message.

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

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

TODO:

 - check roll-back action from parasite, we might need a bitmap
   where status of particular thread mode would be kept

 - eliminate different between trap mode and daemon mode, the
   top-level interface should be parasite_execute() and control
   block should deside self how to deliver the command to parasite
   via trap mode or damon message

 - 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 | 178 +++++++++++++++++++++++++++++++++----
 pie/parasite.c     | 254 +++++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 380 insertions(+), 52 deletions(-)

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


More information about the CRIU mailing list