Commit Graph

51 Commits

Author SHA1 Message Date
Michael Crosby e7542142a8 Remove logging for checkpoint code
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-05-20 15:48:07 -07:00
Andrey Vagin 5f6ea0e8a4 cr: fix parsing of criu version
The format of criu version is X.Y[.Z]. The current code can not parse X.Y,
because scanf returns the "input does not match format" error.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:19:30 -07:00
Andrey Vagin a16d7f1b7d container: don't use c.initProcess before it's set
container.Checkpoint() doesn't clear c.initProcess and
it's used on restore.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
2015-05-20 15:19:30 -07:00
boucher 420180a10b Require criu 1.5.2 rather than 1.5.1
Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
2015-05-20 15:19:30 -07:00
boucher 7c138ebbee Reformat some error handling code and declare descriptor filename as a const.
Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
2015-05-20 15:19:30 -07:00
Andrey Vagin 7d32656ee7 cr: handle all external descriptros in ct.Restore()
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:19:30 -07:00
Andrey Vagin 655f1ce09c Rename StdFds into ExternalDescriptors
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:19:30 -07:00
boucher 3d59a7fe8b Refactor saving fds slightly, set the restored process fds correctly.
Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
2015-05-20 15:19:29 -07:00
boucher 38635c5a11 Move the std_fds into initProcess, and expose them in container's State
Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
2015-05-20 15:19:29 -07:00
boucher 129280ac62 Write the fd info to the image directory during a checkpoint,
and restore with the written info from a given image directory.
Also, write completely root independent ext_mount info.

These changes enable checkpointing in one container and then restoring
into a completely new container.

Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
2015-05-20 15:18:56 -07:00
Hui Kang 46dd56ba07 Change back to --page-server, PageServer should be in CriOpts struct
Docker-DCO-1.1-Signed-off-by: Hui Kang <hkang.sunysb@gmail.com>
2015-05-20 15:18:56 -07:00
root 7a012fe3b5 Allow dumped image to be transferred to a criu page server
--page-server to specify the IP address of criu page server
--port to specify the port of the criu page server

Docker-DCO-1.1-Signed-off-by: Hui Kang <hkang.sunysb@gmail.com>
2015-05-20 15:18:56 -07:00
boucher 4fc7543317 Don't write a "checkpoint" file if the process is left running.
Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
2015-05-20 15:18:56 -07:00
boucher a8d5fdf1fd Add support for providing options to CRIU.
In order to do more complex things with checkpointing
and restoring of containers it's necessary to have
control over where the image files are being saved
and whether or not to kill the running process. It's
possible more flags will be wanted in the future.

Some things probably should always be auto-configured
by libcontainer though.

Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
2015-05-20 15:18:56 -07:00
Andrey Vagin cbe747d989 cr: add a comment about bind-mounting root in a tmp dir
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
Andrey Vagin eaa35f552e cr: add network support
We need to enumirate all veth devices on restore and handle
{un,}lock-network notifications.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
boucher 032aca342e Exclude the root path from mount point paths.
This change was necessary for me to get criu/libcontainer running inside of Docker.

Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
2015-05-20 15:18:56 -07:00
Andrey Vagin 328786f70e cr: don't remove images after restore
This code was added when images were saved in a factory root directory and in
addition this directory was used as a flag.

Now an user can decide when images can be removed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
Andrey Vagin 553b8be2d0 cr: prepare a container root
CRIU has following requirements for a container root:
* it is a mount point
* a parent mount point isn't over-mounted

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
Andrey Vagin 39795424db cr: user criu swrk to dump CT
criu swrk allows to rollback if the /ROOT/CRID/checkpoint
file can't be created. In a future it will be used for locking network.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
Andrey Vagin 6f1d940b8e cr: split the Restore function
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
Andrey Vagin 65f9b1bd84 cr: handle criu notifications in a separate function
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
Andrey Vagin 522f7b36ff cr: Add an ability to specify path for images
the emptye /ROOT/CTID/checkpoint file is created to
support the Checkpointed state.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
Andrey Vagin 5fb0019c45 Add the Checkpointed state
I don't like the current logic in ct.Destroy(). I think ct.Destroy
must destoy ct or return an error.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:56 -07:00
Andrey Vagin 5df3a07b5f cr: split work and image directories
This directory can be removed when criu completes.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:55 -07:00
Andrey Vagin e0f87e2f23 cr: check criu version
CRIU version must be 1.5.1 or higher

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:55 -07:00
Andrey Vagin b836046422 cr: use the RPC protocol for communication with criu
criu swrk is a special mode when we don't want to execute a service,
but want to use RPC.

Here is more details:
http://lists.openvz.org/pipermail/criu/2015-March/019400.html

Another good feature of this mode is that we don't need to create
action scripts and we will be able to remove the hack with saving StdFds.

criu swrk is supported starting with CRIU 1.5.1.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:18:55 -07:00
Andrey Vagin 0eea415019 ct: execute CRIU restore with the --restore-detached option
In this case CRIU will exit after restoring processes. Here is
no reason to wait the init process.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:17:59 -07:00
Andrey Vagin e75d0228cc cr: wait the criu process properly
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:17:59 -07:00
Andrey Vagin b28fbb20a3 cr: don't umount rootfs which was not mounted by us
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:17:59 -07:00
Andrey Vagin f705221b4a go: fmt
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-05-20 15:17:59 -07:00
Saied Kazemi 9212f68293 Some C/R bug fixes and changes in the new libcontainer and nsinit.
This is work in progress, integrating C/R support from
https://github.com/SaiedKazemi/docker/tree/cr into the
new libcontainer and nsinit.

Signed-off-by: Saied Kazemi <saied@google.com>
2015-05-20 15:17:59 -07:00
Michael Crosby f15aba685b Update criu support with restored processes
Also use pipes for non tty so that the parent's tty of the nsinit
process does not leak into the conatiner.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-05-20 15:17:34 -07:00
Michael Crosby da009f5710 Add nsinit support for checkpoint and restore
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-05-20 15:16:13 -07:00
Michael Crosby 6fec5923e3 Add Checkpoint and Restore methods to Container
Containers support checkpointing and restore via criu(8) for linux
containers.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-05-20 15:15:36 -07:00
Qiang Huang e5a7aad7eb Replace aliased imports of logrus
Docker already did this: https://github.com/docker/docker/issues/11762
libcontainer should also do it.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-05-06 21:14:04 +08:00
Michael Crosby 570eed473b Move childPipe to the end of FD set
This adds a new env var for identifying the internal sync pipe that
libcontainer uses to sync with the container and parent process.  This
replaces #496 to allow the user to add additional files to the processes
and not take over fd 3 for all containers.

Closes #496

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-04-08 14:14:51 -07:00
Jörg Thalheim 708b25e61e add option to pass additional fds to container process
This can be usefull to implement socket activated containers for example.

Signed-off-by: Jörg Thalheim <joerg@higgsboson.tk>
2015-04-08 13:56:03 -07:00
Alexander Morozov cbc8dee085 Ensure that state always contains pathes to all namespaces
Thanks coolljit0725 for initial fix.

Closes #512

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-04-07 14:50:08 -07:00
Michael Crosby 46132cebcf Fix pdeathsig and ppid for supervisor running as pid1
For some reason when the supervisor of a container is PID1 the parent
death signal was being delivered to the container's init process even if
it did not die.  Also the ppid() will return 1 for a container running
in the pid namespace of it's parent and the parent is pid1.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-04-02 13:55:55 -07:00
Mrunal Patel ca73d7aede Pass down process Capabilities and apply them if present.
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2015-03-25 15:40:32 -04:00
Qiang Huang d6eb76f8a2 add parameter to Set api
We only have libcontainer.Container on Docker side, can't change `config`
in linuxContainer, pass config to libcontainer so we can change config of
container.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-11 16:46:54 +08:00
Alexander Morozov a9644c209f Add tty support for setnsProcess
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-03-04 17:30:37 -08:00
Mrunal Patel 903680701a Merge pull request #424 from dqminh/fix-generic-error
Fix panic when genericError constructor gets nil error
2015-03-03 20:11:37 -08:00
Daniel, Dao Quang Minh 4ce8d97320 do not pass nil to genericError
currently genericError constructors require not-nil error to be able to read
its Error() message

Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
2015-03-03 22:47:44 -05:00
Qiang Huang 1db687f4f4 add Set api
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-04 08:42:35 +08:00
Alexander Morozov 8d0b06257b Move tty configuration to Process
Now you need to call Process.NewConsole to setup console for process

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-02-25 15:04:43 -08:00
Michael Crosby a36d471a0e Add init path support to allow full control of init binary
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-02-24 17:53:11 -08:00
Alexander Morozov bdff595cad Use configs.NamespaceType as key for State.NamespacePathes
I think this is more convenient because for working with namespaces we
using configs.NamespaceType.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-02-24 11:54:58 -08:00
Andrey Vagin 94fb37f557 process: add Wait(), Signal() and Pid() methods
Currently we have a problem when buffers are used for std file
descriptors.  These buffers are filled from goroutines (Cmd.goroutine),
and we need to wait them to be sure that all data have been copied.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
2015-02-23 23:40:41 +03:00