summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-01 12:04:29 -0800
committerGitHub <noreply@github.com>2019-03-01 12:04:29 -0800
commit2747c20867127c930d705f5162dcd78b4faf9624 (patch)
tree9a52705cf30e667ff097079c501eeb8b11d3066e /libpod
parentc0bc88decc236a7898ba05d9815fb5df7c050f44 (diff)
parent43fe2bf064a4c7e7e24f35abd76acc5add6cc09a (diff)
downloadpodman-2747c20867127c930d705f5162dcd78b4faf9624.tar.gz
podman-2747c20867127c930d705f5162dcd78b4faf9624.tar.bz2
podman-2747c20867127c930d705f5162dcd78b4faf9624.zip
Merge pull request #2485 from adrianreber/oci-check
Verify that used OCI runtime supports checkpoint
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go19
-rw-r--r--libpod/oci.go13
2 files changed, 27 insertions, 5 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index b074efa3a..0e9a5124e 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -472,10 +472,19 @@ func (c *Container) addNamespaceContainer(g *generate.Generator, ns LinuxNS, ctr
return nil
}
-func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointOptions) (err error) {
-
+func (c *Container) checkpointRestoreSupported() (err error) {
if !criu.CheckForCriu() {
- return errors.Errorf("checkpointing a container requires at least CRIU %d", criu.MinCriuVersion)
+ return errors.Errorf("Checkpoint/Restore requires at least CRIU %d", criu.MinCriuVersion)
+ }
+ if !c.runtime.ociRuntime.featureCheckCheckpointing() {
+ return errors.Errorf("Configured runtime does not support checkpoint/restore")
+ }
+ return nil
+}
+
+func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointOptions) (err error) {
+ if err := c.checkpointRestoreSupported(); err != nil {
+ return err
}
if c.state.State != ContainerStateRunning {
@@ -532,8 +541,8 @@ func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointO
func (c *Container) restore(ctx context.Context, options ContainerCheckpointOptions) (err error) {
- if !criu.CheckForCriu() {
- return errors.Errorf("restoring a container requires at least CRIU %d", criu.MinCriuVersion)
+ if err := c.checkpointRestoreSupported(); err != nil {
+ return err
}
if (c.state.State != ContainerStateConfigured) && (c.state.State != ContainerStateExited) {
diff --git a/libpod/oci.go b/libpod/oci.go
index 4bf76f619..2b3cc5db5 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -898,3 +898,16 @@ func (r *OCIRuntime) checkpointContainer(ctr *Container, options ContainerCheckp
args = append(args, ctr.ID())
return utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, args...)
}
+
+func (r *OCIRuntime) featureCheckCheckpointing() bool {
+ // Check if the runtime implements checkpointing. Currently only
+ // runc's checkpoint/restore implementation is supported.
+ cmd := exec.Command(r.path, "checkpoint", "-h")
+ if err := cmd.Start(); err != nil {
+ return false
+ }
+ if err := cmd.Wait(); err == nil {
+ return true
+ }
+ return false
+}